query
stringlengths
7
9.5k
document
stringlengths
10
1.07M
negatives
listlengths
19
19
metadata
dict
DELETE /oeuvres/1 DELETE /oeuvres/1.json
def destroy @oeuvre.destroy respond_to do |format| format.html { redirect_to oeuvres_url, notice: 'Oeuvre was successfully destroyed.' } format.json { head :no_content } end end
[ "def destroy\n @json.destroy\n\n head :no_content\n end", "def destroy\n @egreso = Egreso.find(params[:id])\n @egreso.destroy\n\n respond_to do |format|\n format.html { redirect_to egresos_url }\n format.json { head :no_content }\n end\n end", "def delete_aos_version(args = {}) \n ...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
Represent topic name into more subdomain computable name ie. convert "some_sub_domain" => "some.sub.domain"
def subdomain self.name.gsub('_', '.') end
[ "def subscription_name(topic)\n [\n Cloudenvoy.config.gcp_sub_prefix.tr('.', '-'),\n to_s.underscore,\n topic\n ].join('.')\n end", "def subdomain\n ([self.short_name] + self.class.dalianshops.domain.split('.')[1..-1]).join('.')\n end", "def subdomain_slug\n ...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
Retrieve configuration for the specific +bind_column+ Parameters +bind_column+ this column must be database specific column which are mapped over topic module editor
def module_conf(bind_column) (self.modules && self.modules.reject{|m| m['bind_column'] != bind_column} || []).first end
[ "def param_column\n self.class.param_column\n end", "def get_column_definition\n self.class::ColumnDefinition\n end", "def parameter_definition(column)\n @query_parameter_definitions.find { |param| param.column == column }\n end", "def column_info; end", "def get_postgres_parameter(param...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
Determine the default host, right now the implementation is based on the +self.host_list+ array pop
def default_host host_list.first end
[ "def __default_network_host\n case version\n when /^0|^1/\n '0.0.0.0'\n when /^2/\n '_local_'\n when /^5|^6|^7/\n '_local_'\n else\n raise RuntimeError, \"Cannot determine default network host ...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
To convert +self.hosts+ string into an array of hosts Space and Comma will be used for splitting host string
def host_list return @host_list if defined?(@host_list) if !self.hosts.blank? @host_list = self.hosts.split(/[,\s]+/).compact else @host_list = [] end @host_list end
[ "def hosts\n @hosts ||= match[5].split(\",\")\n end", "def hosts\n host_port.split(\",\")\n end", "def hosts_in_array\n @hosts.strip.split(/\\s+/).map { |i| i.to_i }\n end", "def parse_hosts (args)\n host_arg = (args.empty? || (args[0][0,1] == '-')) ? 'localhost' : args....
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
private. if json_item is a tweet, yield the screen_name/tweet_text/created_at and stop the event loop if block returns true
def yield_if_tweet event_machine, json_item, &block raise "expecting a block" unless block_given? parsed_item = JSON.parse json_item rescue nil screen_name = parsed_item['user']['screen_name'] rescue nil tweet_text = parsed_item['text'] rescue nil created_at = parsed_item['created_at'] rescue nil yield scre...
[ "def twitter_stream twitter_login, content, &block\n raise \"expecting a block\" unless block_given?\n\n stream = Twitter::JSONStream.connect(\n :path => \"/1/statuses/filter.json?#{content}\",\n :auth => twitter_login,\n ...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
synchronously consume a twitter stream and pass each received json_item to yield_if_tweet must be called inside EventMachine::run
def twitter_stream twitter_login, content, &block raise "expecting a block" unless block_given? stream = Twitter::JSONStream.connect( :path => "/1/statuses/filter.json?#{content}", :auth => twitter_login, ...
[ "def yield_if_tweet event_machine, json_item, &block\n raise \"expecting a block\" unless block_given?\n parsed_item = JSON.parse json_item rescue nil\n screen_name = parsed_item['user']['screen_name'] rescue nil\n tweet_text = parsed_item['text'] rescue nil\n created_at = parsed_item['created_at'] rescue nil\...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
GET admin/subcategorias/1 GET admin/subcategorias/1.json
def show @subcategoria = Subcategoria.find(params[:id]) respond_to do |format| format.html # show.html.erb format.json { render :json => @subcategoria } end end
[ "def show\n @subcategoria = Subcategoria.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @subcategoria }\n end\n end", "def show\n @subcategorization = Subcategorization.find(params[:id])\n\n respond_to do |format|\n format.htm...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
GET admin/subcategorias/new GET admin/subcategorias/new.json
def new @subcategoria = Subcategoria.new @subcategoria.status = Status.find_by_descricao('Ativo') respond_to do |format| format.html # new.html.erb format.json { render :json => @subcategoria } end end
[ "def new\n @categorias = Categoria.all\n @subcategoria = Subcategoria.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @subcategoria }\n end\n end", "def create\n @subcategoria = Subcategoria.new(params[:subcategoria])\n\n respond_to do |format|...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
POST admin/subcategorias POST admin/subcategorias.json
def create @subcategoria = Subcategoria.new(params[:subcategoria]) respond_to do |format| if @subcategoria.save format.html { redirect_to [:admin, @subcategoria], :notice => 'Subcategorias was successfully created.' } format.json { render :json => @subcategoria, :status => :created, :loca...
[ "def create\n @subcategoria = Subcategoria.new(params[:subcategoria])\n\n respond_to do |format|\n if @subcategoria.save\n format.html { redirect_to @subcategoria, notice: 'Subcategoria was successfully created.' }\n format.json { render json: @subcategoria, status: :created, location: @sub...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
PUT admin/subcategorias/1 PUT admin/subcategorias/1.json
def update @subcategoria = Subcategoria.find(params[:id]) respond_to do |format| if @subcategoria.update_attributes(params[:subcategoria]) format.html { redirect_to [:admin, @subcategoria], :notice => 'Exemplo was successfully updated.' } format.json { head :ok } else format...
[ "def update\n @subcategoria = Subcategoria.find(params[:id])\n\n respond_to do |format|\n if @subcategoria.update_attributes(params[:subcategoria])\n format.html { redirect_to @subcategoria, notice: 'Subcategoria was successfully updated.' }\n format.json { head :ok }\n else\n f...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
DELETE admin/subcategorias/1 DELETE admin/subcategorias/1.json
def destroy @subcategoria = Subcategoria.find(params[:id]) @subcategoria.update_attributes :status => Status.find_by_descricao('Inativo') respond_to do |format| format.html { redirect_to admin_subcategorias_path } format.json { head :ok } end end
[ "def destroy\n @subcategoria = Subcategoria.find(params[:id])\n @subcategoria.destroy\n\n respond_to do |format|\n format.html { redirect_to subcategorias_url }\n format.json { head :ok }\n end\n end", "def destroy\n @subcategorium = Subcategorium.find(params[:id])\n @subcategorium.de...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
=== Get dam asset locations. Get an asset locations in dam. ==== Parameters options:: (Hash) List of Resource Collection Options shown above can be used as parameter. ==== Example
def get_dam_asset_locations(options) return @client.raw("get", "/content/dam/asset-locations", options) end
[ "def get_dam_asset_locations(options)\n @client.raw('get', '/content/dam/asset-locations', options)\n end", "def locations(opts = {})\n find_collection(\"locations\", opts)\n end", "def query_locations(options={}) path = \"/api/v2/locations\"\n get(path, options, AvaTax::VERSION) ...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
GET /meter_readings/1 GET /meter_readings/1.json
def show @meter_reading = MeterReading.find(params[:id]) respond_to do |format| format.html # show.html.erb format.json { render json: @meter_reading } end end
[ "def index\n @meter_readings = MeterReading.all\n end", "def show\n\n @breadcrumb = 'read'\n @meter_detail = MeterDetail.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @meter_detail }\n end\n end", "def show\n\n ...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
GET /meter_readings/new GET /meter_readings/new.json
def new @meter_reading = MeterReading.new respond_to do |format| format.html # new.html.erb format.json { render json: @meter_reading } end end
[ "def new\n @breadcrumb = 'create'\n @meter_model = MeterModel.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @meter_model }\n end\n end", "def new\n @breadcrumb = 'create'\n @meter_detail = MeterDetail.new\n\n respond_to...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
PUT /meter_readings/1 PUT /meter_readings/1.json
def update @meter_reading = MeterReading.find(params[:id]) respond_to do |format| if @meter_reading.update_attributes(params[:meter_reading]) format.html { redirect_to @meter_reading, notice: 'Meter reading was successfully updated.' } format.json { head :no_content } else f...
[ "def update\n respond_to do |format|\n if @meter_reading.update(meter_reading_params)\n format.html { redirect_to @meter_reading, notice: 'Meter reading was successfully updated.' }\n format.json { render :show, status: :ok, location: @meter_reading }\n else\n format.html { render ...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
DELETE /meter_readings/1 DELETE /meter_readings/1.json
def destroy @meter_reading = MeterReading.find(params[:id]) @meter_reading.destroy respond_to do |format| format.html { redirect_to meter_readings_url } format.json { head :no_content } end end
[ "def destroy\n @meter_reader.destroy\n respond_to do |format|\n format.html { redirect_to admin_meter_readers_url, notice: 'Meter reader was successfully destroyed.' }\n format.json { head :no_content }\n end\n end", "def destroy\n @meter = Meter.find(params[:id])\n @meter.destroy\n\n ...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
Call delete attachment method of message to delete document from backoffice
def delete_document(doc_refno) @message.delete_attachment(current_user, doc_refno) end
[ "def destroy\n @docattachment = Docattachment.find(params[:id])\n @docattachment.destroy\n\n respond_to do |format|\n format.html { redirect_to(docattachments_url) }\n format.xml { head :ok }\n end\n end", "def destroy\n the_name = @attachment.document\n @attachment.destroy\n ...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
Retrieve file from backoffice
def retrieve_file_attachment return unless params[:doc_refno] || params[:type] success, attachments = retrieve_file_details_from_backoffice return unless success send_file_from_attachment(attachments[:attachment]) end
[ "def get_document\n @bookalope.http_get(@url + '/files/document')\n end", "def retrieveFile(path)\n arguments = [self.fullID(path)]\n cmdOptions = {\n \"-a\" => true,\n }\n\n if @account\n cmdOptions[\"-T\"] = @account.token\n end\n\n result = Occam::Worker.perform...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
which file types are allowed to be uploaded.
def content_type_allowlist Rails.configuration.x.file_upload_content_type_allowlist.split(/\s*,\s*/) end
[ "def allowed_file_types\n Rails.configuration.allowed_file_types\n end", "def can_upload?\n klass.model_class && mime_types && mime_types.keys.include?(file_mime_type)\n end", "def file_types\n @file_types ||= config['file_types'] || 'partial'\n end", "def accepted_mimes\n case self.type\n ...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
Used specifically for show method to filter message
def show_message_filter MessageFilter.new(selected_message_smsg_refno: @message.smsg_refno, smsg_original_refno: @message.original_smsg_refno) end
[ "def filter(msg)\n return msg\n end", "def show_filter_info\n initialize_filter_set_if_needed\n @filter_set.message\n end", "def message\n if FilteredTerm.exists?\n msg = read_attribute(:message)\n FilteredTerm.all.each do |t|\n next if msg.blank?\n begin\n ...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
POST /pm/nodes POST /pm/nodes.json
def create @pm_node = Pm::Node.new(pm_node_params) respond_to do |format| if @pm_node.save format.html { redirect_to @pm_node, notice: 'Node was successfully created.' } format.json { render :show, status: :created, location: @pm_node } else format.html { render :new } ...
[ "def post_node()\n @options = {:path => '/nodes/content', :body => Megam::JSONCompat.to_json(\n=begin\n{\n \"systemprovider\" => {\n \"provider\" => {\n \"prov\" => \"chef\"\n }\n },\n \"compute\" => {\n \"ec2\" => {\n \"groups\" => \"megam\",\n \"...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
PATCH/PUT /pm/nodes/1 PATCH/PUT /pm/nodes/1.json
def update respond_to do |format| if @pm_node.update(pm_node_params) format.html { redirect_to @pm_node, notice: 'Node was successfully updated.' } format.json { render :show, status: :ok, location: @pm_node } else format.html { render :edit } format.json { render json: @...
[ "def update\n respond_to do |format|\n if @node_set.update(node_set_params)\n format.html { redirect_to @node_set, notice: 'Node set was successfully updated.' }\n format.json { render :show, status: :ok, location: @node_set }\n else\n format.html { render :edit }\n format.j...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
DELETE /pm/nodes/1 DELETE /pm/nodes/1.json
def destroy @pm_node.destroy respond_to do |format| format.html { redirect_to pm_nodes_url, notice: 'Node was successfully destroyed.' } format.json { head :no_content } end end
[ "def delete_node(node_id)\n @options = {:path => '/nodes/#{node_id}',\n :body => Megam::JSONCompat.to_json({\"node_id\" => \"#{node_id}\"})}.merge(@options)\n\n request(\n :expects => 200,\n :method => :delete,\n #:path => @options[:path],\n :body => @options[...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
Update token sale ended variable Author:Aman Date: 31/10/2017 Reviewed By: Kedar
def update_token_sale_ended_data sale_variable_obj = SaleGlobalVariable.sale_ended.first sale_variable_obj.variable_data = '1' sale_variable_obj.save! end
[ "def renew_token(new_token); end", "def update_user_token\n if is_er_us? && get_user.token && !get_user.token.current?\n get_tokenized_billing_info :subscription_id => get_user.token.subscriptionid, :order_id => get_user.id\n if @net_response.success? && @net_response.params['status'] == 'CURR...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
Returns the path to the response file
def response_file @notifier_engine.response_file end
[ "def file_path\n return @file_path\n end", "def path\n metadata.fetch(:path) do\n return if request_response_pairs.empty?\n request_response_pairs.first.first.path\n end\n end", "def responses_filepath(options)\n options[:responses_filepath] ...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
Adds a lock file to mark the given file as locked
def lock_file file file_lock = file + ".lock" open(file_lock, "w") {} end
[ "def lock_file(file_name, &block); end", "def write_lock\n FileUtils.touch(@lock_file)\n end", "def lock\r\n # already locked, just increase the ref count\r\n if @lock_count > 0\r\n @lock_count += 1\r\n return\r\n end\r\n\r\n # THIS COULD BLOCK\r\n @f.flock(File::LOCK_...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
Deletes a lock file to mark the given file as unlocked
def unlock_file file file_lock = file + ".lock" File.delete(file_lock) if FileTest::file? file_lock end
[ "def remove_lock\n File.delete(@lock_file)\n end", "def remove_lock(filespec)\n File.delete \"#{filespec}.lock\" if File.exists? \"#{filespec}.lock\"\n end", "def close_lock_file\n\t\tif @lockfile\n\t\t\tpath = @lockfile.path\n\t\t\t@lockfile.close\n\t\t\t@lockfile = nil\n\t\t\tFile.delete( path.untaint...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
Checks for a lock file to see if the given file is marked as locked
def is_locked? file file_lock = file + ".lock" FileTest::file? file_lock end
[ "def is_locked?\n if not File.exist? @filename\n return false\n else\n return (File.stat(@filename).mode & 0777) == 0000\n end\n end", "def lock_file_present?(lfname)\n begin\n # TODO check lock file age and send a warning if it is older than a\n # given threshold.\n ...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
Removes emails that have lived in the queue for too long. If max_age is set to 0, no emails will be removed.
def cleanup return if @max_age == 0 timeout = Time.now - @max_age conditions = ['last_send_attempt > 0 and created_on < ?', timeout] mail = ActionMailer::Base.email_class.destroy_all conditions log "expired #{mail.length} emails from the queue" end
[ "def removeExpiredKeywords max_mins\n unless @queue.first.nil?\n # While the keyword at the head of the queue was added more than max_mins ago\n while @queue.first.time + max_mins * 60 < Time.now or @queue.first.nil?\n # If this is the last instance of this keyword then delete it from the hash\...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
Installs signal handlers to gracefully exit.
def install_signal_handlers trap 'TERM' do do_exit end trap 'INT' do do_exit end end
[ "def register_signal_handlers!\n trap('TERM') { shutdown }\n trap('INT') { shutdown }\n end", "def register_signal_handlers\n trap('TERM') { shutdown }\n trap('INT') { shutdown }\n\n begin\n trap('QUIT') { shutdown }\n trap('USR1') { pause_processing }\n trap('...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
Scans for emails and delivers them every delay seconds. Only returns if once is true.
def run install_signal_handlers loop do begin cleanup emails = find_emails deliver(emails) unless emails.empty? rescue ActiveRecord::Transactions::TransactionError end break if @once sleep @delay end end
[ "def mail_flush\n @mails_mutex.synchronize do\n self.log_puts(\"Flushing mails.\") if @debug\n \n if @mails_waiting.empty?\n self.log_puts(\"No mails to flush - skipping.\") if @debug\n return false\n end\n \n self.log_puts(\"Trying to ping Google to figure out if we a...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
Proxy to ActionMailer::Base::smtp_settings. See for instructions on how to configure ActionMailer's SMTP server. Falls back to ::server_settings if ::smtp_settings doesn't exist for backwards compatibility.
def smtp_settings ActionMailer::Base.smtp_settings rescue ActionMailer::Base.server_settings end
[ "def smtp_settings\n smtp = @config[\"smtp\"]\n return unless smtp[\"enabled\"]\n\n {\n address: smtp[\"address\"],\n port: smtp[\"port\"],\n domain: smtp[\"domain\"]\n }.merge(ssl_settings).merge(authentication_settings)\n end", "def smtp_settings\n...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
Returns the configured user name or the user name of the authenticated user
def get_username @user_name ||= self.user.username end
[ "def user_with_name\n user_without_name || user_name\n end", "def get_username\n @user_name ||= user.username\n end", "def get_user_name\n user = Etc.getpwnam(Etc.getlogin)['gecos'].split(',').first\n user = Etc.getlogin if user.nil?\n\n return user\n end", "def hubssolib_get...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
POST /post117s POST /post117s.xml
def create @post117 = Post117.new(params[:post117]) respond_to do |format| if @post117.save format.html { redirect_to(@post117, :notice => 'Post117 was successfully created.') } format.xml { render :xml => @post117, :status => :created, :location => @post117 } else format.h...
[ "def post(data, tags_in = {}) ; post_to nil, data, tags_in end", "def create\n @post168 = Post168.new(params[:post168])\n\n respond_to do |format|\n if @post168.save\n format.html { redirect_to(@post168, :notice => 'Post168 was successfully created.') }\n format.xml { render :xml => @pos...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
Was this notification signalled?
def signalled? @signalled end
[ "def signalled event\n @signalled_actions and @signalled_actions[event]\n end", "def notification?\n false\n end", "def stalled?\n @stalled_fibers.any?\n end", "def should_notify?\n return false if notified\n expiration = default_expiration\n return false unless expirati...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
Grows the set to a larger number of bits.
def grow_to_include(bit) new_size = Math.max(@bits.attr_length << 1, num_words_to_hold(bit)) newbits = Array.typed(::Java::Long).new(new_size) { 0 } System.arraycopy(@bits, 0, newbits, 0, @bits.attr_length) @bits = newbits end
[ "def set_bits\n bits = []\n 0.upto(63) {|i| bits << i if set?(i)}\n bits\n end", "def NEEDBITS(n)\n while @@bits < (n)\n PULLBYTE()\n end\n end", "def BITS(n)\n (@@hold & ((1 << (n)) - 1))\n end", "def shift_size= n\n @mutex.synchronize do @shift_size = n end\n end", "def multi...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
complement bits in the range minBit..maxBit.
def not_in_place(min_bit, max_bit) # make sure that we have room for maxBit grow_to_include(max_bit) i = min_bit while i <= max_bit n = word_number(i) @bits[n] ^= bit_mask(i) i += 1 end end
[ "def bitwise_complement(n)\n return 1 if n == 0\n n ^ (1<<n.bit_length)-1\nend", "def twos_complement(num)\n return 256 + num\nend", "def complement( value )\n diff = value - self.begin\n result = (self.end - diff)\n return result\n end", "def not\n ~@bits\n end", "def flippingBits(n)\n...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
Subtract the elements of 'a' from 'this' inplace. Basically, just turn off all bits of 'this' that are in 'a'.
def subtract_in_place(a) if ((a).nil?) return end # for all words of 'a', turn off corresponding bits of 'this' i = 0 while i < @bits.attr_length && i < a.attr_bits.attr_length @bits[i] &= ~a.attr_bits[i] i += 1 end end
[ "def subtract!(rhs)\n subtract rhs, self\n end", "def -(other)\n other.inject(clone) do |copy, e|\n copy.delete e\n copy\n end\n end", "def rsub(o); -self + o; end", "def -(other_list)\n without_list = self.class.copy_list(self)\n other_list.list.each do |item, int_value|\n ...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
Create a string representation where instead of integer elements, the ith element of vocabulary is displayed instead. Vocabulary is a Vector of Strings. separator The string to put in between elements
def to_s(separator, vocabulary) if ((vocabulary).nil?) return to_s(nil) end str = "" i = 0 while i < (@bits.attr_length << LOG_BITS) if (member(i)) if (str.length > 0) str += separator end if (i >= vocabulary.size) str +...
[ "def key_with_separator(separator)\n segments.join(separator)\n end", "def pp_vector(vector)\n puts vector.map { |y| y.inspect[1...-1].split('').join(' ') + ' , ' }.join[0...-3]\n print_new_line\nend", "def list_all_words\r\n @vocabularies.sort.each do |name, words|\r\n puts \"In vocab...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
Dump a commaseparated list of the words making up the bit set. Split each 64 bit number into two more manageable 32 bit numbers. This generates a commaseparated list of C++like unsigned long constants.
def to_string_of_half_words s = StringBuffer.new i = 0 while i < @bits.attr_length if (!(i).equal?(0)) s.append(", ") end tmp = @bits[i] tmp &= 0xffffffff s.append(tmp) s.append("UL") s.append(", ") tmp = @bits[i] >> 32 ...
[ "def long()\n\t\t\twords = []\n\t\t\t7.downto(0) do |x|\n\t\t\t\tword = (@addr >> 16*x) & 0xffff \n\t\t\t\twords.push( word.to_s(16).rjust(4, \"0\") )\n\t\t\tend\n\t\t\treturn words.join(':')\n\t\tend", "def to_string_of_words\n s = StringBuffer.new\n i = 0\n while i < @bits.attr_length\n if...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
Dump a commaseparated list of the words making up the bit set. This generates a commaseparated list of Javalike long int constants.
def to_string_of_words s = StringBuffer.new i = 0 while i < @bits.attr_length if (!(i).equal?(0)) s.append(", ") end s.append(@bits[i]) s.append("L") i += 1 end return s.to_s end
[ "def to_string_of_half_words\n s = StringBuffer.new\n i = 0\n while i < @bits.attr_length\n if (!(i).equal?(0))\n s.append(\", \")\n end\n tmp = @bits[i]\n tmp &= 0xffffffff\n s.append(tmp)\n s.append(\"UL\")\n s.append(\", \")\n tmp = ...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
GET /release_loans/1 GET /release_loans/1.json
def show @release_loan = ReleaseLoan.find(params[:id]) respond_to do |format| format.html # show.html.erb format.json { render json: @release_loan } end end
[ "def new\n @release_loan = ReleaseLoan.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @release_loan }\n end\n end", "def loans\n url = \"#{LOANS_PATH}/pre-approved\"\n data = perform_get(url)\n data || {}\n end", "de...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
GET /release_loans/new GET /release_loans/new.json
def new @release_loan = ReleaseLoan.new respond_to do |format| format.html # new.html.erb format.json { render json: @release_loan } end end
[ "def new\n @lounge = Lounge.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @lounge }\n end\n end", "def new\n @lost = Lost.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @lost }\n end\n end"...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
POST /release_loans POST /release_loans.json
def create @release_loan = ReleaseLoan.new(params[:release_loan]) respond_to do |format| if @release_loan.save format.html { redirect_to @release_loan, notice: 'Release loan was successfully created.' } format.json { render json: @release_loan, status: :created, location: @release_loan } ...
[ "def new\n @release_loan = ReleaseLoan.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @release_loan }\n end\n end", "def create\n user = User.find_by(name: params[:loan][:name])\n @loan = user.loans.build(loan_params)\n @loan.on_loan ||= true\...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
PUT /release_loans/1 PUT /release_loans/1.json
def update @release_loan = ReleaseLoan.find(params[:id]) respond_to do |format| if @release_loan.update_attributes(params[:release_loan]) format.html { redirect_to @release_loan, notice: 'Release loan was successfully updated.' } format.json { head :no_content } else format....
[ "def create\n @release_loan = ReleaseLoan.new(params[:release_loan])\n\n respond_to do |format|\n if @release_loan.save\n format.html { redirect_to @release_loan, notice: 'Release loan was successfully created.' }\n format.json { render json: @release_loan, status: :created, location: @rele...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
DELETE /release_loans/1 DELETE /release_loans/1.json
def destroy @release_loan = ReleaseLoan.find(params[:id]) @release_loan.destroy respond_to do |format| format.html { redirect_to release_loans_url } format.json { head :no_content } end end
[ "def delete_aos_version(args = {}) \n delete(\"/aosversions.json/#{args[:aosVersionId]}\", args)\nend", "def delete_floor_plan(args = {}) \n delete(\"/files.json/floorplan/images\", args)\nend", "def delete_aos_version_box(args = {}) \n delete(\"/aosversions.json/aosversionbox/#{args[:aosVersionBoxId]}\", args)...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
Root breadcrumbs setup method. May be overridden or augmented by subclasses
def set_breadcrumbs @breadcrumbs = [] add_breadcrumb "Home", root_path end
[ "def init_breadcrumbs\n @list_of_breadcrumbs = [[ 'base', base_path ], [ controller_name, nil ], [ nil, action_name ]]\n set_breadcrumb_path( self.send( controller_name + '_path' ))\n rescue NoMethodError\n end", "def before_breadcrumb_callbacks; end", "def auto_set_breadcrumb\n ariane.add(\"Home\"...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
Log action, along with record_id, section, and id from params, plus any optional params (which overwrite the default params if there are duplicates)
def audit_log(action, optional_params = {}) description = params.slice(:record_id, :section, :id).merge(optional_params).map { |key, value| "#{key}:#{value}"}.join('|') requester = current_user.try(:email) || 'NONE' AuditLog.create(event: action, description: description, requester_info: requester) desc...
[ "def record(action, *arguments)\n log \"#{action_padding(action)}#{action} #{arguments.join(' ')}\"\n end", "def log_action action, job, *stuff\n Log.info [action, job.loggable, *stuff].flatten.join(\"\\t\")\n end", "def update_log\n recorded_user = begin\n current_resour...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
input: array of integers output: array containing running total for each element data structure: integer array algorithim: initialise `sum` equal to `0` initialise `running_total` empty array iterate over array argument increment `sum` by current element append `sum` to `running_total` return `running_total` Examples:
def running_total(array) sum = 0 running_total = [] array.each do |element| sum += element running_total << sum end running_total end
[ "def running_total arr\n totals = []\n sum = 0\n arr.each do |elm|\n sum += elm\n totals << sum\n end\n totals\nend", "def running_total(arr)\n res = []\n running_total = 0\n\n arr.each do |element|\n running_total += element\n res << running_total\n end\n\n res\nend", "def running_total(a...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
POST /feed_entries POST /feed_entries.xml
def create @feed_entry = FeedEntry.new(params[:feed_entry]) respond_to do |format| if @feed_entry.save flash[:notice] = 'FeedEntry was successfully created.' format.html { redirect_to(@feed_entry) } format.xml { render :xml => @feed_entry, :status => :created, :location => @feed_...
[ "def create_feed\n @feed = Feed.new(params[:feed])\n\n respond_to do |format|\n if @feed.save\n EntryFeed.create_from_feed(@feed)\n format.html { redirect_to @feed, :notice => 'Feed was successfully created.' }\n format.json { render :json => @feed, :status => :created, :location => ...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
DELETE /feed_entries/1 DELETE /feed_entries/1.xml
def destroy @feed_entry = FeedEntry.find(params[:id]) @feed_entry.destroy respond_to do |format| format.html { redirect_to(feed_entries_url) } format.xml { head :ok } end end
[ "def destroy\n @feed = Feed.find(params[:id])\n current_user.feeds.delete @feed\n current_user.save!\n\n respond_to do |format|\n format.html { redirect_to(root_path) }\n format.xml { head :ok }\n end\n end", "def destroy\n @feed = Feed.find(params[:id])\n @feed.destroy\n\n res...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
Laptops fleet_type Can be: :all, :spares, :staff, :archived Return a table of inwarranty laptops.
def print_laptops(fleet_type) simple_print(@snipe.laptops(fleet_type), %w(asset_tag serial name assigned_to.username), 'asset_tag', ['Asset Tag', 'Serial', 'Asset Name', 'Assigned To']) end
[ "def print_laptops_in_warranty(fleet_type)\n laptops = @snipe.laptops(fleet_type)\n data = laptops.find_all {|i| i['in_warranty'] }\n simple_print(data, %w(warranty_expires.formatted asset_tag serial name assigned_to.username), 'warranty_expires.formatted', ['Warranty Expires', 'Asset Tag', 'Serial', 'Asse...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
Return a table of inwarranty laptops.
def print_laptops_in_warranty(fleet_type) laptops = @snipe.laptops(fleet_type) data = laptops.find_all {|i| i['in_warranty'] } simple_print(data, %w(warranty_expires.formatted asset_tag serial name assigned_to.username), 'warranty_expires.formatted', ['Warranty Expires', 'Asset Tag', 'Serial', 'Asset Name',...
[ "def table_for(rpt)\n Inkblot::Components::TableList.new do |tl|\n tl.div_height = :full\n tl.div_width = 95\n\n tl.font_size = [30, 18, 12, 18]\n tl.text_align = :center\n tl.items = []\n\n tl.items << rpt[:symbol]\n tl.items << \"$#{rpt[:latest...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
Return a table of laptops sorted by age. Age is approximate. This method does not calculate the intricacies of leap years, etc.
def print_laptops_by_age(fleet_type, older_than_years = 0.0) laptops = @snipe.laptops(fleet_type) older_than_years = older_than_years.to_f data = [] # Do not include these very old assets if filtering by age if older_than_years == 0.0 # Format assets that have word based asset_tags, such as '...
[ "def sorted_by_age\n sort_by { |llama|\n llama.age\n }\n end", "def sorted_by_age\n end", "def sorted_by_age(people)\nend", "def sort_tenants_by_age tenants\n return tenants.sort_by { |tenant| tenant.age }\n end", "def adults\n travelers.select { |traveler| traveler.is_adult? }.sort_by(&...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
Delete any old channel requests (since they were approved)
def destroy_channel_request channel_request = ChannelRequest.where(:user_id => self.subscriber_id, :channel_id => self.channel_id).first channel_request.destroy unless channel_request.blank? end
[ "def delete_requests\n self.requests.each {|request| request.destroy}\n end", "def revert_redeem_requests\n if subscription_status == 'canceled'\n redeem_requests = user.redeem_requests.where(:created_at.gte => created_at, :created_at.lte => updated_at, status: false)\n redeem_requests.destroy_al...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
POST /kpi_types POST /kpi_types.json
def create @kpi_type = KpiType.new(kpi_type_params) if @kpi_type.save flash[:success] = 'KPI Type was successfully created.' redirect_to :back else flash[:danger] = 'KPI Type was not created.' redirect_to :back end end
[ "def add_dummy_type\n params[:data] ||= {}\n params[:data][:type] = resource_klass._type.to_s\n end", "def create_types\n\t\t[]\n\tend", "def pet_types\r\n BnetApi::make_request('/wow/data/pet/types')\r\n end", "def create\n @pit_type = PitType.new(pit_type_params)\n\n respond_to do |...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
PATCH/PUT /kpi_types/1 PATCH/PUT /kpi_types/1.json
def update if @kpi_type.update(kpi_type_params) flash[:success] = 'KPI Type was successfully updated.' redirect_to :back else flash[:danger] = 'KPI Type was not updated.' redirect_to :back end end
[ "def update\n respond_to do |format|\n if @patch_type.update(patch_type_params)\n format.html { redirect_to admin_patch_types_path, notice: 'Patch type was successfully updated.' }\n format.json { render :index, status: :ok, location: @patch_type }\n else\n...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
DELETE /kpi_types/1 DELETE /kpi_types/1.json
def destroy @kpi_type.destroy flash[:success] = 'KPI Type was successfully deleted.' redirect_to :back end
[ "def destroy\n @pit_type.destroy\n respond_to do |format|\n format.html { redirect_to pit_types_url }\n format.json { head :no_content }\n end\n end", "def delete_type(id)\n delete(\"/types/#{id}\")\n end", "def destroy\n @ot_type = OtType.find(params[:id])\n @ot_type.destr...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
add_suffix "somefile.xml", "_1234" => somefile_1234.xml""
def add_suffix filename, suffix parts = filename.split("\.") base = parts[0..-2] parts2 = base << suffix << parts[-1] fn = parts2.join(".") end
[ "def append_suffix(filename, suffix)\n return filename.match(/\\.#{suffix}$/) ? filename.to_s : \"#{filename}.#{suffix}\"\n end", "def test_add_filename_suffix_ext\n assert_equal('path/to/file-a.json',\n add_filename_suffix('path/to/file.json', '-a'))\n assert_equal('/path/to/file-a....
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
PATCH/PUT /audits/1 PATCH/PUT /audits/1.json
def update respond_to do |format| if @audit.update(audit_params) format.html { redirect_to @audit, notice: 'Audit was successfully updated.' } format.json { render :show, status: :ok, location: @audit } else format.html { render :edit } format.json { render json: @audit.e...
[ "def update\n @audit = Audit.find(params[:id])\n\n respond_to do |format|\n if @audit.update_attributes(params[:audit])\n format.html { redirect_to @audit, notice: 'Audit was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
DELETE /audits/1 DELETE /audits/1.json
def destroy @audit.destroy respond_to do |format| format.html { redirect_to audits_url, notice: 'Audit was successfully destroyed.' } format.json { head :no_content } end end
[ "def destroy\n @audit = Audit.find(params[:id])\n @audit.destroy\n\n respond_to do |format|\n format.html { redirect_to audits_url }\n format.json { head :no_content }\n end\n end", "def destroy\n \n @audit = current_user.audits.find(params[:id])\n @audit.destroy\n \n UserMailer...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
Renders a notification field for a Redmine::Notifiable option
def notification_field(notifiable) tag_data = if notifiable.parent.present? {:parent_notifiable => notifiable.parent} else {:disables => "input[data-parent-notifiable=#{notifiable.name}]"} end tag = check_box_tag('settings[notified_events][]', notifiable...
[ "def render_notification_message(notification, options = {})\n format_message(notification, options)\n end", "def notification_text(notification)\n notifiable = notification.notifiable\n text = if notification.medium?\n t('notifications.new_medium')\n elsif notification...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
Returns the options for the date_format setting
def date_format_setting_options(locale) Setting::DATE_FORMATS.map do |f| today = ::I18n.l(User.current.today, :locale => locale, :format => f) format = f.delete('%').gsub(/[dmY]/) do {'d' => 'dd', 'm' => 'mm', 'Y' => 'yyyy'}[$&] end ["#{today} (#{format})", f] end end
[ "def default_options_date_format(format)\n format || '%Y-%m-%d - %l:%M:%S%p'\n end", "def date_format_options\n Import::DATE_FORMATS.map do |f|\n format = f.delete('%').gsub(/[dmY]/) do\n {'d' => 'DD', 'm' => 'MM', 'Y' => 'YYYY'}[$&]\n end\n [format, f]\n end\n end", "def date_f...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
GET /orf_models/1 GET /orf_models/1.json
def show @orf_model = OrfModel.find(params[:id]) respond_to do |format| format.html # show.html.erb format.json { render json: @orf_model } end end
[ "def get_models\n\t\tam = ErAppModel.where(er_user_app_id: @ua.id)\n\t\t@status = 200\n\t\t@res = am \n\t\trender json: @res , status: @status\t\t\t\n\tend", "def load_model_info\n JSON.parse(RestClient.get(model_info_url))\n end", "def new\n @orf_model = OrfModel.new\n\n respond_to do |format|\n ...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
Called before a task is created, sends a request to the Scale API
def create_task #Assign url url="https://api.scaleapi.com/v1/task/phonecall" #Auth credentials setup auth = {:username=>ENV["SCALE_API_KEY"], :password=>""} #Assign headers headers = {"Content-Type"=>"application/json"} #Create payload params = {callback_url: 'https://mysterious-...
[ "def start\n descriptor['starts'].each do |task_name|\n create_task(nil, task_name, payload)\n end\n end", "def task_start\n dataset = @user.datasets.find(params[:id])\n raise ActiveRecord::RecordNotFound unless dataset\n klass = AnalysisTask.job_class(params[:class])\n \n # Put...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
Parse callback from Scale on the survey and assign response to a model
def parse_response(response) if response["outcome"]=="success" #Assign calorie counts and grams breakdown self.total_calories=response["fields"]["total_calories"].to_i self.protein_grams=response["fields"]["total_calories"].to_i self.fat_grams=response["fields"]["fat_grams"].to_i sel...
[ "def parse(savon_response)\n response = new(savon_response)\n response.raw[\"#{key}_response\".to_sym][\"#{key}_result\".to_sym][:response_type]\n end", "def create_task\n\n #Assign url\n url=\"https://api.scaleapi.com/v1/task/phonecall\"\n\n #Auth credentials setup\n auth = {...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
execute a command against a remote windows machine using psexec
def psexec(host, command) exec = "psexec \\\\#{Array(host).join ','}" if @options[:user] exec << " -u \"#{@options[:user]}\"" @options[:password] = ask("--> Enter password for #{@options[:user]}@#{host}: ") {|q| q.echo = '*'} unless @options[:password] exec << " -p \"#{@opt...
[ "def psexec(ip)\n\t\tpayload = 'windows/meterpreter/bind_tcp'\n\t\tpsexec = framework.modules.create(\"exploit/windows/smb/psexec\")\n\t\tpsexec.datastore['PAYLOAD'] = 'windows/meterpreter/bind_tcp'\n\t\tpsexec.datastore['MODULE_OWNER'] = self.owner\n\t\tpsexec.datastore['WORKSPACE'] = datastore[\"WORKSPACE\"] if d...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
returns the number of students in this section
def count_students students.size end
[ "def num_grades (student)\n @grades[student].length\n end", "def num_grades(student)\n @grades[student].length\n end", "def total_students\n registrations.\n inject(0) {|total, registration| total + registration.number_of_students }\n end", "def active_student_count\n if self.s...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
Calculate the checksum from the page (or the pre packed data) If data it supplied it will be updated to record the checksum value
def compute_checksum(data_) data = data_.dup data[22..25] = [0].pack("V") crc = 0 data.each_byte do |byte| crc = (crc << 8)^CHECKSUM_TABLE[((crc >> 24)&0xff) ^ byte] crc = crc & 0xffffffff end crc end
[ "def calcChecksum(data)\n \n # calculate checksum\n checksum = 0xFF\n data.each_byte {|x| checksum ^= x }\n \n return checksum\n end", "def checksum\n @checksum ||= calculate_checksum\n end", "def checksum!# {{{\n self.csum = compute_checksum\n end", "def checksum;...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
POST /mergegraphs POST /mergegraphs.json
def create @mergegraph = Admin::Mergegraph.new(mergegraph_params) respond_to do |format| if @mergegraph.save format.html { redirect_to @mergegraph, notice: 'Mergegraph was successfully created.' } format.json { render action: 'show', status: :created, location: @mergegraph } else ...
[ "def create\n @graph = Graph.new(params[:graph])\n\n respond_to do |format|\n if @graph.save\n Action.log :controller => params[:controller], :action => params[:action], :target_id => @graph.id, :user => current_user\n format.html { redirect_to @graph, notice: 'Graph was successfully create...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
PATCH/PUT /mergegraphs/1 PATCH/PUT /mergegraphs/1.json
def update respond_to do |format| if @mergegraph.update(mergegraph_params) format.html { redirect_to @mergegraph, notice: 'Mergegraph was successfully updated.' } format.json { head :no_content } else @merge = Admin::Merge.find(@mergegraph.merge_id) format.html { render a...
[ "def update\n @complex_graph = ComplexGraph.find(params[:id])\n @complex_graph.graphs = Graph.where(:id => (params[:graph] || []).map{|id,_| id })\n\n respond_to do |format|\n if @complex_graph.update_attributes(params[:complex_graph])\n format.html { redirect_to @complex_graph, :notice => 'Com...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
DELETE /mergegraphs/1 DELETE /mergegraphs/1.json
def destroy @mergegraph.destroy respond_to do |format| format.html { redirect_to admin_mergegraph_url } format.json { head :no_content } end end
[ "def destroy\n @graph = Graph.find(params[:id], :select => \"id\")\n @graph.destroy\n\n respond_to do |format|\n format.html { redirect_to(graphs_url) }\n format.xml { head :ok }\n end\n end", "def destroy\n @graph.destroy\n\n respond_to do |format|\n format.html { redirect_to g...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
Redefines an object's method with a Command of the same name.
def redefine_command(obj, command) cmd_block = redefine_command_block(obj, command) @no_option_commands << command if command.options.nil? [command.name, command.alias].compact.each {|e| obj.singleton_class.send(:define_method, e, cmd_block) } rescue Error warn "Error: #{$!.mes...
[ "def redefine_command(obj, command)\n cmd_block = redefine_command_block(obj, command)\n @no_option_commands << command if command.options.nil?\n [command.name, command.alias].compact.each {|e|\n obj.instance_eval(\"class<<self;self;end\").send(:define_method, e, cmd_block)\n }\n end",...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
Returns hash of methods for an object
def object_methods(obj) @object_methods[obj] ||= {} end
[ "def to_hash\n hash = {}\n\n self.singleton_methods.each do |method|\n hash[method] = self.send method\n end\n\n hash\n end", "def define_hash_method(methods)\n define_method(:hash) do\n self.class.hash ^ methods.map { |method| send(method).hash }.inject(:^)\n end\n ...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
option command for given command
def option_command(cmd=@command) @option_commands[cmd] ||= OptionCommand.new(cmd) end
[ "def option(command_option)\n self << \" -#{command_option}\"\n self\n end", "def opt(command_option)\n self << \" --#{command_option}\"\n self\n end", "def find_command(option)\n @commands.find { |cmd| cmd.short == option or cmd.extended == option }\n end", "def ...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
A name is valid is if satisfies all of the following: contains at least a first name and last name, separated by spaces each part of the name should be capitalized Hint: use str.upcase or str.downcase "a".upcase => "A"
def is_valid_name(str) str_arr = str.split check = [] str_arr.each do |ele| formatted = ele[0].upcase + ele[1..-1].downcase check << formatted end if check.length < 2 || check.join(" ") != str return false else return true end end
[ "def is_valid_name(str)\n \n parts = str.split(\" \")\n \n if parts.length <= 1\n return false\n end\n \n # now we need to check that each part is properly capitalized\n parts.each do |part|\n if !is_proper(part)\n return false\n end\n end\n\n return true\nend", "def user_name_format\n ...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
Sets the owner attributes on the given record
def set_owner_attributes(record) if @owner.persisted? construct_owner_attributes.each { |key, value| record[key] = value } end end
[ "def set_record_ownerable(record=current_record)\n access_denied(\"Record in set_record_ownerable is blank.\") if record.blank?\n access_denied(record, \"Record does not respond to ownerable.\") unless record_respond_to_ownerable?(record)\n @record_ownerable = record.send(own...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
Returns a hash linking the owner to the association represented by the reflection
def construct_owner_attributes(reflection = @reflection) attributes = {} if reflection.macro == :belongs_to attributes[reflection.association_primary_key] = @owner.send(reflection.primary_key_name) else attributes[reflection.primary_key_name] = @owner.send(reflectio...
[ "def owner\r\n @property_hash[:owner]\r\n end", "def owner_dic\n if self.owner_id && @owner = Company.find(self.owner_id)\n return @owner.dic\n else\n return \"\"\n end\n end", "def association_owner_key(assoc, key)\n k = 'activerecord.associations.models.'\n k << assoc.active_reco...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
Private: checks the mapper policy against its class opts The Hash containing the policy filter data. Return: true if it fulfills the policy and false if it does not.
def verify_policy(opts) result = policy.constantize.call(opts) rescue NameError result = true ensure return result end
[ "def check_policy(policy)\n if policy\n allow = (policy['policy'] == 'allow') ? true : false\n return allow == (check_restriction(policy['caller'], 'fact') &&\n check_restriction(policy['classes'], 'class') &&\n check_restriction(policy['c...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
publishes to a channel some data (can be anything)
def publish(channel, data) send_action('publish', channel, data) end
[ "def publish(channel, data, id=nil, prev_id=nil)\n @pub.publish(channel, Item.new(JsonObjectFormat.new(data), id, prev_id))\n end", "def publish_data(channel, data)\n redis = EM::Hiredis.connect(Settings.redis)\n redis.publish(channel, data).callback do\n # only close connection after complete the ...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
unsubscribes all clients subscribed to a channel
def unsubscribe_clients(channel) send_action('unsubscribe_clients', channel) end
[ "def unsubscribe_all\n @subscribed_channels.each do |channel_name|\n unsubscribe channel_name\n end\n end", "def unsubscribe(*channels); end", "def unsubscribe_from_channel; end", "def unsubscribe_all\n @subscribers.clear if defined? @subscribers\n end", "def unsubscribe chan...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
method used to send messages to the webserver checks too see if the message is a hash and if it is it will transform it to JSON and send it to the webser otherwise will construct a JSON object that will have the key action with the value 'message" and the key message witth the parameter's value
def chat(message) final_message = nil if message.is_a?(Hash) final_message = message.to_json else final_message = JSON.dump(action: 'message', message: message) end log_to_file("#{self.class} sends JSON #{final_message}") send_data(final_message) end
[ "def send_message\n send_user_id, target_user_id, content = params[:send_user_id], params[:target_user_id], params[:conent]\n message_hash = {\n send_user_id: send_user_id,\n target_user_id: target_user_id,\n content: content\n }.keep_if{|k,v| v.presen...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
Send the data given by the data param if running on a posix system this uses Ruby's fork method to send if on windows fork won't be attempted. +data+:: the data to send +type+:: :text or :binary, defaults to :text
def send_data(data, type = :text) pid = Thread.new do do_send(data, type) end end
[ "def send(data, type = :text)\n if IS_WINDOWS\n do_send(data, type) #fork not supported on windows\n else\n pid = fork do\n do_send(data, type)\n end\n Process.detach(pid)\n end\n end", "def send_data(data)\n str_data = data.pack('C*')\n super(str_d...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
this method is lifted from image_processing gem copies the original image to a tempfile because we don't want to mess with the original
def _copy_to_tempfile(file) args = [File.basename(file.path, ".*"), File.extname(file.path)] if file.respond_to?(:path) tempfile = Tempfile.new(args || "image", binmode: true) IO.copy_stream(file, tempfile.path) file.rewind tempfile end
[ "def _copy_to_tempfile(file)\n args = [File.basename(file.path, \".*\"), File.extname(file.path)] if file.respond_to?(:path)\n tempfile = Tempfile.new(args || \"image\", binmode: true)\n IO.copy_stream(file, tempfile.path)\n file.rewind\n tempfile\n end", "def adjust_image tempfile\n ...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
playing one round of game till the word is not found in the dictionary
def play_round until dictionary.include?(fragment) && fragment != "" puts "Current player : #{current_player.name}" add_letter(current_player) print "Current fragment of a word: " puts "'#{fragment}'".green next_player! end if losses[previous_player] + 1 == "ghost".length ...
[ "def check_player_words(player_guess_word)\n word.chomp.chars.each_with_index{\n |item, index|\n if item == player_guess_word.chomp.chars[index].to_s # exactly equal and in the same postion\n result = \"Exact\"\n elsif word.chomp.include?(player_guess_word.chars[index].to_s) # just includes...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
End of test method test_Currency_001_CommaDelimit =========================================================================== Testcase method: test_Currency_002_Format_To_Amount Description: Tests WatirWorks method: format_to_currency(...) Attempts to convert strings to amounts =========================================...
def test_Currency_002_Format_To_Amount puts2("") puts2("#######################") puts2("Testcase: test_Currency_002_Format_To_Amount") puts2("#######################") begin # convert_ToCurrency ############################ sThisTaskName = "1000 to $1,000.00" puts2(" # BEGIN: "...
[ "def test_Currency_003_Format_From_Amount\n\n\n puts2(\"\")\n puts2(\"#######################\")\n puts2(\"Testcase: test_Currency_003_Format_From_Amount\")\n puts2(\"#######################\")\n\n begin # convert_StringFromCurrency\n\n\n ############################\n sThisTaskName = \"$1,...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
End of test method test_Currency_002_Format_To_Amount ============================================================================= Testcase method: test_Currency_003_Format_From_Amount Description: Tests WatirWorks method: format_from_currency(...) Attempts to convert amounts to strings ===============================...
def test_Currency_003_Format_From_Amount puts2("") puts2("#######################") puts2("Testcase: test_Currency_003_Format_From_Amount") puts2("#######################") begin # convert_StringFromCurrency ############################ sThisTaskName = "$1,000 to 1000" puts2("...
[ "def test_Currency_002_Format_To_Amount\n\n puts2(\"\")\n puts2(\"#######################\")\n puts2(\"Testcase: test_Currency_002_Format_To_Amount\")\n puts2(\"#######################\")\n\n begin # convert_ToCurrency\n\n ############################\n sThisTaskName = \"1000 to $1,000.00\"...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
GET /tipo_actividads GET /tipo_actividads.json
def index @tipo_actividads = TipoActividad.all end
[ "def index\n @tipoactividads = Tipoactividad.all\n end", "def index\n @tipo_actividades = TipoActividad.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render :json => @tipo_actividades }\n end\n end", "def show\n @tipo_actividad = TipoActividad.find(para...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
POST /tipo_actividads POST /tipo_actividads.json
def create @tipo_actividad = TipoActividad.new(tipo_actividad_params) respond_to do |format| if @tipo_actividad.save format.html { redirect_to @tipo_actividad, notice: 'Tipo actividad se creó correctamente.' } format.json { render :show, status: :created, location: @tipo_actividad } ...
[ "def create\n @tipo_actividad = TipoActividad.new(params[:tipo_actividad])\n\n respond_to do |format|\n if @tipo_actividad.save\n format.html { redirect_to @tipo_actividad, :notice => 'Tipo Actividad creada satisfactoriamente.' }\n format.json { render :json => @tipo_actividad, :status => :...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
DELETE /tipo_actividads/1 DELETE /tipo_actividads/1.json
def destroy @tipo_actividad.destroy respond_to do |format| format.html { redirect_to tipo_actividads_url, notice: 'Tipo actividad se elimino correctamente.' } format.json { head :no_content } end end
[ "def destroy\n @tipo_actividad = TipoActividad.find(params[:id])\n @tipo_actividad.destroy\n\n respond_to do |format|\n format.html { redirect_to tipo_actividads_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @tipo_actividad = TipoActividad.find(params[:id])\n @...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
POST /informacoes_ged POST /informacoes_ged.json
def create @informacao_ged = InformacaoGed.new(informacao_ged_params) respond_to do |format| if @informacao_ged.save format.html { redirect_to @informacao_ged, notice: 'Informação sobre o GED criada com sucesso.' } format.json { render action: 'show', status: :created, location: @informac...
[ "def create\n @gigibecali = Gigibecali.new(params[:gigibecali])\n\n respond_to do |format|\n if @gigibecali.save\n format.html { redirect_to @gigibecali, :notice => 'Gigibecali was successfully created.' }\n format.json { render :json => @gigibecali, :status => :created, :location => @gigib...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
PATCH/PUT /informacoes_ged/1 PATCH/PUT /informacoes_ged/1.json
def update respond_to do |format| if @informacao_ged.update(informacao_ged_params) format.html { redirect_to @informacao_ged, notice: 'Informação sobre o GED atualizada com sucesso.' } format.json { head :no_content } else format.html { render action: 'edit' } format.json...
[ "def update\n @ubicacion_geografica = UbicacionGeografica.find(params[:id])\n\n respond_to do |format|\n if @ubicacion_geografica.update_attributes(params[:ubicacion_geografica])\n format.html { redirect_to @ubicacion_geografica, notice: 'Ubicacion geografica was successfully updated.' }\n ...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
DELETE /informacoes_ged/1 DELETE /informacoes_ged/1.json
def destroy @informacao_ged.destroy respond_to do |format| format.html { redirect_to informacoes_ged_url } format.json { head :no_content } end end
[ "def destroy\n @ubicacion_geografica = UbicacionGeografica.find(params[:id])\n @ubicacion_geografica.destroy\n\n respond_to do |format|\n format.html { redirect_to ubicaciones_geograficas_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @agronomiaquimica = Agronomiaq...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
GET /status_de_la_inscripcions GET /status_de_la_inscripcions.json
def index @status_de_la_inscripcions = StatusDeLaInscripcion.all respond_to do |format| format.html # index.html.erb format.json { render json: @status_de_la_inscripcions } end end
[ "def index\n @status_del_pago_de_la_inscripcions = StatusDelPagoDeLaInscripcion.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @status_del_pago_de_la_inscripcions }\n end\n end", "def index\n @status_de_la_notificacions = StatusDeLaNotificacion.al...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
GET /status_de_la_inscripcions/1 GET /status_de_la_inscripcions/1.json
def show @status_de_la_inscripcion = StatusDeLaInscripcion.find(params[:id]) respond_to do |format| format.html # show.html.erb format.json { render json: @status_de_la_inscripcion } end end
[ "def index\n @status_de_la_inscripcions = StatusDeLaInscripcion.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @status_de_la_inscripcions }\n end\n end", "def index\n @status_del_pago_de_la_inscripcions = StatusDelPagoDeLaInscripcion.all\n\n re...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
GET /status_de_la_inscripcions/new GET /status_de_la_inscripcions/new.json
def new @status_de_la_inscripcion = StatusDeLaInscripcion.new respond_to do |format| format.html # new.html.erb format.json { render json: @status_de_la_inscripcion } end end
[ "def new\n @status_del_pago_de_la_inscripcion = StatusDelPagoDeLaInscripcion.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @status_del_pago_de_la_inscripcion }\n end\n end", "def new\n @status_de_la_notificacion = StatusDeLaNotificacion.new\n\n ...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
POST /status_de_la_inscripcions POST /status_de_la_inscripcions.json
def create @status_de_la_inscripcion = StatusDeLaInscripcion.new(params[:status_de_la_inscripcion]) respond_to do |format| if @status_de_la_inscripcion.save format.html { redirect_to @status_de_la_inscripcion, notice: 'Status de la inscripcion was successfully created.' } format.json { re...
[ "def create\n @inscripcion = Inscripcion.new(inscripcion_params)\n\n respond_to do |format|\n if @inscripcion.save\n format.html { redirect_to @inscripcion, notice: 'Inscripcion was successfully created.' }\n format.json { render :show, status: :created, location: @inscripcion }\n else...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
PUT /status_de_la_inscripcions/1 PUT /status_de_la_inscripcions/1.json
def update @status_de_la_inscripcion = StatusDeLaInscripcion.find(params[:id]) respond_to do |format| if @status_de_la_inscripcion.update_attributes(params[:status_de_la_inscripcion]) format.html { redirect_to @status_de_la_inscripcion, notice: 'Status de la inscripcion was successfully updated.'...
[ "def update\n respond_to do |format|\n if @inscripcione.update(inscripcione_params)\n format.html { redirect_to @inscripcione, notice: 'Inscripcione was successfully updated.' }\n format.json { render :show, status: :ok, location: @inscripcione }\n else\n format.html { render :edit...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
SHOW / HIDE FORM Hides the Use of Collections Information form
def hide_uoc_info_form logger.info 'Hiding the Use of Collections Info form' wait_for_element_and_click form_show_hide_button('Use of Collections Information') end
[ "def hide_uoc_info_form\n wait_for_element_and_click form_show_hide_button('Use of Collections Information')\n end", "def hidden_options; end", "def hide_in_overview\n @hide_in_overview = true\n end", "def hide(name)\n base_fields[name] = base_fields[name].dup\n base_fields[name].widget ...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }