query stringlengths 7 9.5k | document stringlengths 10 1.07M | negatives listlengths 19 19 | metadata dict |
|---|---|---|---|
Redirect users in accounts in bad standing to billing page | def check_access
redirect_to billing_path, flash: { error: "Your account is inactive. Access will be restored once payment succeeds." } if current_account.try(:inactive?)
end | [
"def check_access\n redirect_to billing_path,\n flash: {\n error: \"Your trial has ended or your subscription has been cancelled. Please update your card - access will be restored once payment succeeds.\"\n }\n end",
"def redirect_when_paid\n if request.method == \"GET\"\n i... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
returns the wikis for the project. | def wikis
set_attributes_for(Wiki)
Wiki.find(:all)
end | [
"def wikis\n cmd = {\"cmd\"=>\"listWikis\",\"token\"=>@token}\n result = Hpricot.XML(@connection.post(@api_url,to_params(cmd)).body)\n raise FogBugzError, \"Code: #{(result/\"error\")[0][\"code\"]} - #{(result/\"error\").inner_html}\" if (result/\"error\").inner_html != \"\"\n list_process(result,\"wiki... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
returns the property definitions for the project. | def property_definitions
set_attributes_for(PropertyDefinition)
PropertyDefinition.find(:all)
end | [
"def properties()\n @properties ||= begin\n pom = %w(groupId artifactId version packaging).inject({}) { |hash, key|\n value = project[key] || (parent ? parent.project[key] : nil)\n hash[key] = hash[\"pom.#{key}\"] = hash[\"project.#{key}\"] = value_of(value) if value\n hash\n ... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
returns the murmurs for the project. | def murmurs
set_attributes_for(Murmur)
Murmur.find(:all)
end | [
"def milestones\n names = self.milestone_names\n return [] if !names or !self.project # 24-Jul-2013: or !self.project because a request can be associated to a stream and no project\n self.project.milestones.select{|m| names.include?(m.name)}\n end",
"def all_movers\n m = []\n movement_groups.wher... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
lookup status of job by asking actor running it | def get_job_status(job)
status = nil
if job.present?
if job.is_a?(Hash)
job = job.stringify_keys
actor = @registered_jobs[job['id']]
status = actor.status
else
actor = @registered_jobs[job.to_i]
status = actor.status
end
end
... | [
"def get_job_status()\n if convert_version(\"1.3.7\") <= @version\n return talk(\"GET-JOB-STATUS\") rescue \"None job found.\"\n end\n end",
"def get_job_status id\n end",
"def job_status\n Sidekiq::Status::status(self.jid) || self.status\n end",
"def get_status_job(gear, component)... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Default headers we send to active campaign Accept/content type json ApiToken for authentication | def default_headers
@default_headers ||= {
'accept': 'json',
'content-type': 'application/json',
'Api-Token': api_key
}
end | [
"def get_default_headers(content_type: nil)\n {\n 'Authorization' => \"Bearer #{self.valid_access_token['access_token']}\",\n 'Accept' => content_type || 'application/json',\n 'Content-Type' => content_type || 'application/json',\n 'x-app-id' => 'single-cell-portal',\n 'x-domain-id' => \... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
def is_pass_fail_type? criteria_type == Constants::CRITERIA_TYPE_PASS_FAIL end def is_point_type? criteria_type == Constants::CRITERIA_TYPE_POINT end | def get_status
if criteria_type == Constants::CRITERIA_TYPE_PASS_FAIL
temp_status = status
else
temp_status = point.zero? ? Constants::CRITERIA_STATUS_FAILED : Constants::CRITERIA_STATUS_PASSED
end
temp_status
end | [
"def student_selects_points\n return case self.case_type\n when \"case_a\" then true\n when \"case_b\" then true\n else false\n end\n end",
"def valid_criteria_type # :nodoc:\n {\n 'between' => 'between',\n 'not between' => 'notBetween'... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
To make things even harder to read, we'll remove spaces too. For example, this string: two drums and a cymbal fall off a cliff can be disemvoweled to get: twdrmsndcymblfllffclff We also want to keep the vowels we removed around (in their original order), which in this case is: ouaaaaoai | def remove_vowels(string)
vowels = ['a', 'e', 'i', 'o', 'u']
final_string = ""
vowels_used = ""
string.gsub!(" ", "")
string.each_char do |letter|
if !(vowels.include?(letter))
final_string << letter
else
vowels_used << letter
end
end
[final_string, vowels_used]
end | [
"def cleanup(str)\n words = str.split\n letters_only = ''\n words.each do |word|\n letters = word.split('')\n letters.each do |letter|\n if /[a-z]/.match(letter)\n letters_only << letter\n else\n letters_only << ' '\n end\n end\n letters_only << ' '\n end\n letters_only... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
The MFS API exposes a FileToken creation via several different URLs. However we will never want to create a file token that we do not already have a file to hand, and hence we only use the FileStore URL. | def create(file, properties = {})
path = @file_repository.path_for(file, 'createfiletoken')
@client.post(path, properties).tap do |token|
token.file = file
end
end | [
"def token_store\n Google::Auth::Stores::FileTokenStore.new(file: file_token_store_path)\n end",
"def save(file_token, file)\n create(file, {\n :RedirectWhenExpiredUrl => file_token.redirect_when_expired_url,\n :Unlimited => file.unlimited,\n :MaxDownloadAt... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
As an alternative a FileToken object can be created and the appropriate values set, then the save method called which creates the token on the server and its details loaded. | def save(file_token, file)
create(file, {
:RedirectWhenExpiredUrl => file_token.redirect_when_expired_url,
:Unlimited => file.unlimited,
:MaxDownloadAttempts => file.max_download_attempts,
:MaxDownloadSuccesses => file.max_download_successes
})
e... | [
"def save_token(token_info)\n puts \"checking token\"\n @token = get_token\n token_info['timestamp'] = Time.now\n token_file = File.open TOKEN_FILE, 'w'\n token_file.write YAML.dump token_info\n token_file.flush\n token_file.close\nend",
"def create_token access_token: nil\n auth_token = ::AuthToken... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
UITableView delegate for default contents of UITableView, and UISearchDisplayController's UISearchResultsTableView | def tableView(table_view, numberOfRowsInSection: section)
case
when table_view.instance_of?(UITableView)
if @venues
@venues.length
else
0
end
when table_view.instance_of?(UISearchResultsTableView)
if @user_searched_venues
@user_searched_venues.length
els... | [
"def index_table(klass, objects)\n # get links from class' helper\n links = send(\"#{klass.table_name}_index_links\", objects).compact\n\n # if there are any batch links, insert the 'select all' link\n batch_ops = !links.reject{|l| !l.match(/class=\"batch_op_link\"/)}.empty?\n links.insert(0, select_... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Checks each way matches the live version and deletes it if it does not. | def refresh_way
@osm.way.each_key do |way|
@log.info('refreshing ' + way)
response = query_server('/way/' + way)
if !response.nil?
xml = StringIO.new(response)
importer = Xml_import_osm.new(@new_osm)
listner = Listener.new(impor... | [
"def free!\n return false if matches.empty?\n match_preference_indexes = matches.map { | match | preferences.index match }\n max = match_preference_indexes.max # The index of the match with the lowest preference\n candidate_to_reject = preferences[ max ]\n\n # Dele... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
GET /zoneamentos/1 GET /zoneamentos/1.json | def show
@zoneamento = Zoneamento.find(params[:id])
respond_to do |format|
format.html # show.html.erb
format.json { render :json => @zoneamento }
end
end | [
"def index\n @zones = Zone.all\n render json: @zones\n #@zones\n end",
"def index\n @zones = Zone.all\n\n render json: @zones\n end",
"def show\n render json: @ozones\n end",
"def index\n @ozones = Ozone.all\n render json: @ozones\n end",
"def show\n @zone = @shop.zones.find p... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
GET /zoneamentos/new GET /zoneamentos/new.json | def new
@zoneamento = Zoneamento.new
respond_to do |format|
format.html # new.html.erb
format.json { render :json => @zoneamento }
end
end | [
"def new\n @zone = Zone.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @zone }\n end\n end",
"def create\n @zoneamento = Zoneamento.new(params[:zoneamento])\n\n respond_to do |format|\n if @zoneamento.save\n format.html { redirect_to ... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
POST /zoneamentos POST /zoneamentos.json | def create
@zoneamento = Zoneamento.new(params[:zoneamento])
respond_to do |format|
if @zoneamento.save
format.html { redirect_to @zoneamento, :notice => 'Zoneamento was successfully created.' }
format.json { render :json => @zoneamento, :status => :created, :location => @zoneamento }
... | [
"def create\n @zone = Zone.new(zone_params)\n\n if @zone.save\n render json: @zone, status: :created, location: @zone\n else\n render json: @zone.errors, status: :unprocessable_entity\n end\n end",
"def create\n @objeto = Zona.new(zona_params)\n\n respond_to do |format|\n if @obj... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
PUT /zoneamentos/1 PUT /zoneamentos/1.json | def update
@zoneamento = Zoneamento.find(params[:id])
respond_to do |format|
if @zoneamento.update_attributes(params[:zoneamento])
format.html { redirect_to @zoneamento, :notice => 'Zoneamento was successfully updated.' }
format.json { head :no_content }
else
format.html { r... | [
"def update\n respond_to do |format|\n if @objeto.update(zona_params)\n set_redireccion\n format.html { redirect_to @redireccion, notice: 'Zona was successfully updated.' }\n format.json { render :show, status: :ok, location: @objeto }\n else\n format.html { render :edit }\n... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
DELETE /zoneamentos/1 DELETE /zoneamentos/1.json | def destroy
@zoneamento = Zoneamento.find(params[:id])
@zoneamento.destroy
respond_to do |format|
format.html { redirect_to zoneamentos_url }
format.json { head :no_content }
end
end | [
"def destroy\n @zona.destroy\n respond_to do |format|\n format.html { redirect_to zonas_url, notice: 'Se ha eliminado la Zona.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n @zona = Zona.find(params[:id])\n @zona.destroy\n\n respond_to do |format|\n format.htm... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
use init_cairo_bind(true) when initializing the screen Texture or you might run into some trouble :x | def init_cairo_bind(dry=false)
args = if self.disposed? || dry
[width, height];
else
dumpdata = dump('bgra');
format = Cairo::Format::ARGB32;
stride = Cairo::Format.stride_for_width(format, width);
[dumpdata, format, width, height, stride];
end
@_cairo_surface = Cairo::... | [
"def begin_canvas\n if @width && @height\n @surface = ::Cairo::ImageSurface.new(::Cairo::FORMAT_ARGB32, @width, @height)\n else\n @surface = ::Cairo::ImageSurface.from_png(@file)\n end\n bind_context\n end",
"def init_opengl\n bcm_host_init\n \n # Get an EGL display c... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
This method is not yet implemented. This method (should) extracts previously stored data for reuse. options [Hash]:: A hash that is passed to this extension by the main LEWT program containing rutime options. | def extract( options )
end | [
"def run(options = {})\n start_time = Time.now\n update_data_results = update_data(options.merge(started_at: start_time)) || {}\n # we may get a string back, or something else\n update_data_results = { output: update_data_results.to_s } unless update_data_results.is_a?(Hash)\n report_run_re... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Captures the extract data and converts it to a YML string storing it as a property on this object. Returns an empty array so as not to interupt the process loop. options [Hash]:: A hash that is passed to this extension by the main LEWT program containing rutime options. data [Hash]:: The extracted data as a hash. | def process( options, data )
@extractData = data.to_yaml
return []
end | [
"def render( options, data )\n @processData = data.to_yaml\n name = options[:store_filename]\n yml = options[:store_hook] == \"extract\" ? @extractData : @processData\n name != nil ? store(yml, name ) : [yml]\n end",
"def extract( options )\n \n end",
"def populate(options = {})\n... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Captures proess data and converts it to a YML string. This method also handles the actual writing of data to the file system. The options 'store_hook' toggles exract or process targeting. options [Hash]:: A hash that is passed to this extension by the main LEWT program containing rutime options. data [Array]:: The proc... | def render( options, data )
@processData = data.to_yaml
name = options[:store_filename]
yml = options[:store_hook] == "extract" ? @extractData : @processData
name != nil ? store(yml, name ) : [yml]
end | [
"def process( options, data )\n @extractData = data.to_yaml\n return []\n end",
"def save_data\n puts \"saving data\"\n\n File.open(generate_filename(self), \"w\") do |f|\n f.write(ostruct_to_hash(self.json).to_yaml)\n end\n end",
"def stash_data\n path = self.class.gamesave_path\... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Writes the given YAML string to a file at path/name.yml, this method will overwrite the file if it already exists. yml [String]:: A YAML string of data. path [String]:: The path to store too. name [String]:: The name of the file to save as. | def store ( yml, name )
storefile = File.new( name, "w")
storefile.puts(yml)
storefile.close
return [yml]
end | [
"def save_yaml(path, config)\n File.open(path, \"w\") do |f|\n f.write(YAML.dump(config))\n end\n end",
"def save_yaml(path=nil)\n unless path\n # Display file explorer\n path = Qt::FileDialog.getSaveFileName(self, \"Save configuration file\", \"./myconfig.yml\", \"YAML Fi... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
GET /document_histories GET /document_histories.json | def index
@document_histories = DocumentHistory.all
respond_to do |format|
format.html # index.html.erb
format.json { render json: @document_histories }
end
end | [
"def index\n @document_histories = DocumentHistory.all\n end",
"def index\n @docs_histories = DocsHistory.all\n end",
"def index\n @histories = History.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @histories }\n end\n end",
"def index\n... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
GET /document_histories/new GET /document_histories/new.json | def new
@document_history = DocumentHistory.new
respond_to do |format|
format.html # new.html.erb
format.json { render json: @document_history }
end
end | [
"def new\n @title = t('view.documents.new_title')\n @document = Document.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @document }\n end\n end",
"def new\n \n @document = Document.new\n\n respond_to do |format|\n format.html # new.html... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
POST /document_histories POST /document_histories.json | def create
@document_history = DocumentHistory.new(params[:document_history])
respond_to do |format|
if @document_history.save
format.html { redirect_to @document_history, notice: 'Document history was successfully created' }
format.json { render json: @document_history, status: :created,... | [
"def index\n @document_histories = DocumentHistory.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @document_histories }\n end\n end",
"def index\n @document_histories = DocumentHistory.all\n end",
"def new\n @document_history = DocumentHisto... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
PUT /document_histories/1 PUT /document_histories/1.json | def update
@document_history = DocumentHistory.find(params[:id])
respond_to do |format|
if @document_history.update_attributes(params[:document_history])
format.html { redirect_to @document_history, notice: 'Document history was successfully updated.' }
format.json { head :no_content }
... | [
"def update\n respond_to do |format|\n if @document_history.update(document_history_params)\n format.html { redirect_to documents_url, notice: 'Document history was successfully updated.' }\n format.json { render :show, status: :ok, location: @document_history }\n else\n format.htm... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
DELETE /document_histories/1 DELETE /document_histories/1.json | def destroy
@document_history = DocumentHistory.find(params[:id])
@document_history.destroy
respond_to do |format|
format.html { redirect_to document_histories_url }
format.json { head :no_content }
end
end | [
"def destroy\n @document_history.destroy\n respond_to do |format|\n format.html { redirect_to document_histories_url, notice: 'Document history was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n @docs_history.destroy\n respond_to do |format|\n ... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
This method is called with a block to define a provider for some subtree of the MIB. When a request comes in with varbinds in that providers subtree, the provider's handlers will be called to generate the varbind to send back in the response PDU. Arguments oid: The root OID of the MIB subtree this provider is responsib... | def provide(oid = :all, &block)
provider = Provider.new(oid)
provider.instance_eval(&block)
# Providers are pushed onto the end of the provider queue.
# When dispatching, this is searched in order for a match.
# So, like exception handlers, you such specify providers
# in order of m... | [
"def configure_providers(node, node_details, node_name)\n # General provider-specific settings\n providers = node_details['providers']\n providers && providers.each do |provider_type, provider_params|\n node.vm.provider provider_type do |node_provider|\n provider_params.each do |key, value| \n n... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Collects responses for the given message from the available providers | def dispatch(message)
response_pdu = message.make_response_pdu
context = ProviderDsl.new
context.message = message
context.response_pdu = response_pdu
message.pdu.varbinds.each_with_index do |vb, index|
context.varbind = vb
provider = providers.find { |p| p.provides?(vb.oid... | [
"def backfill_message_response_events\n imported_event_count = 0\n\n log(\"Processing #{messages.count} messages:\\n\")\n messages.find_each do |message|\n log('*') and next unless message.user_id == message.consult.initiator_id\n log('*') and next if last_seen_message_ids[message.consult_id] > m... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Evan Manuella Marsha Fletcher Here, we are creating a system which will allow the user to input an image and a function (e.g: rgbredder). This function will be applied to every pixel in the image (e.g: making the image redder). Outline tile = PixeledTile.new(image_to_intial_tile(image) tile.transform!(fun) tile.export(... | def image_compute(imageID, active_layer, function)
tile = PixeledTile.new(image_to_initial_tile(imageID, active_layer))
while tile
tile.transform!(function)
tile = tile.update()
end
end | [
"def image_transform(imageID, active_layer, function)\n tile = PixeledTile.new(image_to_initial_tile(imageID, active_layer))\n while tile\n tile.transform!(function)\n tile = tile.export() #send tile to gimp, get new one, and set tile to it\n end #If no tile is next (the end), then image_compute will termi... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Return the number of product attributes that this product has. | def attribute_count
product_family.product_attributes.size
end | [
"def attribute_count()\n #This is a stub, used for indexing\n end",
"def number_of_attributes\n\t\treturn self.attributes.size\n\tend",
"def size\n @components.values.inject(0) { |component_count, attribute| component_count + attribute.size }\n end",
"def n_col\n retur... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Used as pseudoattribute by the products controller. Add this product to the specified leaf categories. The list of leaf categories is assumed to be comprehensive: the product should be assigned to all these leaves and only these leaves. For each leaf, propagate the product all the way up to the root. | def leaf_ids=(lids)
save! if new_record?
# Clear out all mention of the product from the entire tree.
CategoryProduct.delete_all(["product_id = ?", self.id])
lids.each do |lid|
next if lid == "none"
category = Category.find(lid)
category.add_product(self, auto_prop)
end
end | [
"def add_product(prod, propagate = true)\n\n # Can't add products to interior category.\n unless self.leaf?\n errors.add(:base, \"Can't add product to interior category.\")\n return\n end\n \n # Make sure that the category has the product's product family.\n # There is a race condition h... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Return an array of the leaf category ids for this product. | def leaf_ids
lids = []
self.categories.leaves.each do |cat|
lids << cat.id
end
lids
end | [
"def category_ids\n categories.order(&:level).collect(&:id)\n end",
"def category_ids\n [category_id].flatten\n end",
"def categories\n parent_category_id = product_category.id\n cats = []\n while parent_category_id != nil\n c = Tienda::ProductCategory.find(parent_category_id)\... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Merge an indicator into 'leaf_category_paths' that tells if the current product is visible in that path. | def candidate_paths
# All leaf categories for this product family. This is an array
# of hashes. Each hash has keys :catid and :path.
candidates = self.product_family.leaf_category_paths
# All leaf category ids that were previously selected for this
# product. This will be a subset of the candida... | [
"def leaf_category_paths\n paths = []\n # 'leaves' is a named scope on the category association collection.\n self.categories.leaves.each do |cat|\n paths << {:catid => cat.id, :path => cat.full_path}\n end\n paths\n end",
"def draw_child_paths?\n true\n end",
"def uncategorized... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Get the value of the the given attribute for this product. | def get_attribute_value(attribute)
values = read_attr_val(attribute.id)
return nil unless values
if attribute.atype == ProductAttribute::Atype_String
return values[0]
elsif attribute.atype == ProductAttribute::Atype_Currency
MoneyUtils.format(values[1])
else
return Integer(values[1... | [
"def attribute_value\n end",
"def attribute_value\n end",
"def get_value(attribute_id)\n get_custom_value_hash\n return @custom_value_hash[attribute_id]\n end",
"def get_value(attribute)\n local_val = instance_variable_get(\"@#{attribute}\")\n local_val.nil? ? YieldStarClient.send... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Set the value of this product for a given attribute. | def set_attribute_value(attribute, value)
# This product needs to have an id in order to set
# attribute values on it.
save! if new_record?
if attribute.atype == ProductAttribute::Atype_String
str_val = value
int_val = nil
elsif attribute.atype == ProductAttribute::Atype_Currency
... | [
"def set_Attribute(value)\n set_input(\"Attribute\", value)\n end",
"def set_attribute(name, value); end",
"def set_attribute(name, value)\n @attributes[name] = value\n end",
"def set_AttributeValue(value)\n set_input(\"AttributeValue\", value)\n end",
"def []=(attrib... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
initialize memache if client is storing results in memcache | def initialize_memcache
require 'memcache'
memcache_options = {
:c_threshold => 10_000,
:compression => true,
:debug => false,
:namespace => 'backgroundrb_result_hash',
:readonly => false,
:urlencode => false
}
@cache = MemCache.new(memcache_option... | [
"def initial_cache; end",
"def initialize(memcached, client)\n @memcached = memcached\n @client = client\n @fetched_records_time = {}\n end",
"def using_memcached\n clone(cache_store: Wrest::Caching::Memcached.new)\n end",
"def initialize\n @cache = {}\n end",
"def shared_c... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
end of method establish_connections every 10 request or 10 seconds it will try to reconnect to bdrb servers which were down | def discover_server_periodically
@disconnected_connections.each do |key,connection|
connection.establish_connection
if connection.connection_status
@backend_connections << connection
connection.close_connection
@disconnected_connections[key] = nil
end
en... | [
"def without_reconnect(&blk); end",
"def without_reconnect(&block); end",
"def _maybe_reconnect()\r\n\t\tif @request_count >= @reconnect_interval\r\n\t\t\t$LOG.debug(\"Completed #{@request_count} requests using this connection, reconnecting...\")\r\n\t\t\t_close_socket(@connection)\r\n\t\t\t@node_id, @connectio... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
find the local configured connection | def find_local
find_connection("#{BackgrounDRb::BDRB_CONFIG[:backgroundrb][:ip]}:#{BackgrounDRb::BDRB_CONFIG[:backgroundrb][:port]}")
end | [
"def default_connection\n @default_connection ||= connect(:auto)\n end",
"def connection\n if connected?\n connections[connection_name] || default_connection\n else\n raise NoConnectionEstablished\n end\n end",
"def get_connection(name)... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Update the stats and discover new nodes if they came up. | def update_stats
@request_count += 1
discover_server_periodically if(time_to_discover? && !@disconnected_connections.empty?)
end | [
"def update_nodes(nodes)\n old = dup\n replace(nodes)\n each do |node|\n if (i = old.find_node_index(node.name))\n node.stats = old[i].stats\n node.last = old[i].last\n end\n rescue Oxidized::NodeNotFound\n end\n sort_by! { |x| x.last.nil? ? Time.new(0)... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Send worker information of all currently running workers from all configured bdrb servers | def all_worker_info
update_stats
info_data = {}
@backend_connections.each do |t_connection|
info_data[t_connection.server_info] = t_connection.all_worker_info rescue nil
end
return info_data
end | [
"def all_worker_info(t_data)\n info_response = []\n reactor.live_workers.each do |key,value|\n worker_key = (value.worker_key.to_s).gsub(/#{value.worker_name}_?/,\"\")\n info_response << { :worker => value.worker_name,:worker_key => worker_key,:status => :running }\n end\n send_obj... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
choose a server in round robin manner. | def choose_server
if @round_robin.empty?
@round_robin = (0...@backend_connections.length).to_a
end
if @round_robin.empty? && @backend_connections.empty?
discover_server_periodically
raise NoServerAvailable.new("No BackgrounDRb server is found running") if @round_robin.empty? &&... | [
"def next_primary(ping = nil, session = nil)\n ServerSelector.primary.select_server(self, nil, session)\n end",
"def evaluate!\n @servers ||= Array(callback[options]).map do |server|\n case server\n when String then Net::SSH::Multi::Server.new(master, server, options)\n els... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
=begin Copyright 20062008 the V8 project authors. All rights reserved. Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met: Redistributions of source code must retain the above copyright notice, this list of conditions and the fol... | def encodeURIComponent(componentString)
::URI::URIEncodeComponent(componentString)
end | [
"def encode_string_ex; end",
"def url_encode(string) \r\n encoded_string = ''\r\n string.each_char do |char|\r\n char = (\"%%%02X\" % char.ord) if char.match(/[A-Za-z0-9]/) == nil\r\n encoded_string << char\r\n end\r\n return encoded_string\r\n end",
"def encode(string); end",
"def encod... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
POST /asanas POST /asanas.json | def create
@asana = Asana.new(asana_params)
respond_to do |format|
if @asana.save
format.html { redirect_to @asana, notice: 'Asana criado com sucesso.' }
format.json { render :show, status: :created, location: @asana }
else
format.html { render :new }
format.json { r... | [
"def create_allele(a)\n allele_data = request(\n :url => \"alleles.json\",\n :method => \"post\",\n :payload => { :allele => a }.to_json\n )\n allele = JSON.parse(allele_data)[\"allele\"]\n return allele\nend",
"def post(*a) route 'POST', *a end",
"def create\n @taco = Taco.new(taco_para... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Save this Data Bag Item via RESTful API | def save(item_id = @raw_data["id"])
r = chef_server_rest
begin
if Chef::Config[:why_run]
Chef::Log.warn("In why-run mode, so NOT performing data bag item save.")
else
r.put("data/#{data_bag}/#{item_id}", self)
end
rescue Net::HTTPClientException => e
... | [
"def save\n params = { name: @name }\n self.metadata.each { |key, value| params[key] = value }\n @bookalope.http_post(@url, params)\n end",
"def save\n raise SaveError.new(\"Cannot save a deleted resource\") if deleted?\n\n if @data['id'].to_s.empty?\n remote_call({ method: 'POST', param... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Create this Data Bag Item via RESTful API | def create
chef_server_rest.post("data/#{data_bag}", self)
self
end | [
"def create_item(data_bag, item_name, data = {}, metadata = {})\n item = ::SecureDataBag::Item.new(metadata)\n item.raw_data = { 'id' => item_name }.merge(data)\n item.data_bag data_bag\n item\n end",
"def create_item\n props = {\n bibIds: [create_bib],\n it... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Gets the maximum header sizes for this RTSP profile. This is the largest RTSP request or response header that the RTSP filter (control channel) will allow before aborting the connection. | def maximum_header_size
super
end | [
"def max_header_length\n @max_header_length ||= @headers_options[:names].values.inject(0) { |max_length, name| max_length < name.length ? name.length : max_length }\n end",
"def find_max_header_count\n @max_header_count = (@summaries.map{|s| s.headers.try(:size) || 0} + [1]).max\n end",
"def ma... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Gets the maximum queued data sizes for this RTSP profile. This is the maximum amount of data that the RTSP filter (control channel) will buffer before assuming the connection is dead and subsequently aborting the connection. | def maximum_queued_data_size
super
end | [
"def max_size\n data[:max_size]\n end",
"def system_queue_size\n @cached_queue_size = get_request(\"/system/queue-size\")[\"value\"]\n rescue => error\n if JSON.parse(error.message)[\"code\"] == 429 && @cached_queue_size\n return @cached_queue_size\n end\n raise e... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Gets the states to indicate whether to allow redirection of multicasts for this RTSP profile. If enabled, the client is allowed to select the destination where data will be streamed. | def multicast_redirect_state
super
end | [
"def set_multicast_redirect_state(opts)\n opts = check_params(opts,[:states])\n super(opts)\n end",
"def allowed_outbound_data_transfer_destinations\n return @allowed_outbound_data_transfer_destinations\n end",
"def multicast?\n (@addr & 0x0100000000000000) != 0 && !b... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Gets the RTP port for this RTSP profile. | def rtp_port
super
end | [
"def rtp_port=(port)\n @rtp_port = port\n @rtcp_port = @rtp_port + 1\n end",
"def src_port\n if (@src_port.length == 1)\n return @src_port[0]\n end\n return @src_port\n end",
"def destination_port\n return @destination_port\n end",
"def nat_desti... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Gets the states to indicate whether to allow redirection of unicasts for this RTSP profile. If enabled, the client is allowed to select the destination where data will be streamed. | def unicast_redirect_state
super
end | [
"def set_unicast_redirect_state(opts)\n opts = check_params(opts,[:states])\n super(opts)\n end",
"def allowed_inbound_data_transfer_sources\n return @allowed_inbound_data_transfer_sources\n end",
"def enable_all_stream_targets\n return self.endpoint.enable_all_stre... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Sets the maximum header sizes for this RTSP profile. This is the largest RTSP request or response header that the RTSP filter (control channel) will allow before aborting the connection. | def set_maximum_header_size(opts)
opts = check_params(opts,[:sizes])
super(opts)
end | [
"def maximum_header_size\n super\n end",
"def max_header_length\n @max_header_length ||= @headers_options[:names].values.inject(0) { |max_length, name| max_length < name.length ? name.length : max_length }\n end",
"def set_max_message_size(opts)\n opts = check_params(opts,[:max_message... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Sets the maximum queued data sizes for this RTSP profile. This is the maximum amount of data that the RTSP filter (control channel) will buffer before assuming the connection is dead and subsequently aborting the connection. | def set_maximum_queued_data_size(opts)
opts = check_params(opts,[:sizes])
super(opts)
end | [
"def maximum_queued_data_size\n super\n end",
"def max_message_size=(value)\n @max_message_size = value\n end",
"def maximum_message_size=(size)\n set_attribute(\"MaximumMessageSize\", size.to_s)\n end",
"def set_max_message_size(opts)\n opts = check_params(o... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Sets the states to indicate whether to allow redirection of multicasts for this RTSP profile. If enabled, the client is allowed to select the destination where data will be streamed. | def set_multicast_redirect_state(opts)
opts = check_params(opts,[:states])
super(opts)
end | [
"def set_unicast_redirect_state(opts)\n opts = check_params(opts,[:states])\n super(opts)\n end",
"def multicast_redirect_state\n super\n end",
"def set_bridge_multicast_state(opts)\n opts = check_params(opts,[:states])\n super(opts)\n end",
"def unicast_redirect_state\n ... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Sets the proxy types that this RTSP filters are associated with. | def set_proxy_type(opts)
opts = check_params(opts,[:types])
super(opts)
end | [
"def proxytype=(value)\n Ethon.logger.warn(\n \"ETHON: Easy#proxytype= is deprecated. \"+\n \"Please use Easy#proxy= with protocoll handlers.\"\n )\n Curl.set_option(:proxytype, value_for(value, :string), handle)\n end",
"def types=(types)\n @types = Array(types) i... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Sets the RTCP port for this RTSP profile. | def set_rtcp_port(opts)
opts = check_params(opts,[:ports])
super(opts)
end | [
"def rtp_port=(port)\n @rtp_port = port\n @rtcp_port = @rtp_port + 1\n end",
"def set_rtp_port(opts)\n opts = check_params(opts,[:ports])\n super(opts)\n end",
"def remote_port=(value)\n @remote_port = value\n end",
"def port=(value)\n @port = value\n ... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Sets the RTP port for this RTSP profile. | def set_rtp_port(opts)
opts = check_params(opts,[:ports])
super(opts)
end | [
"def rtp_port=(port)\n @rtp_port = port\n @rtcp_port = @rtp_port + 1\n end",
"def set_rtcp_port(opts)\n opts = check_params(opts,[:ports])\n super(opts)\n end",
"def rtp_port\n super\n end",
"def port=(value)\n @port = value\n end",
"def destination_port=(value)\n ... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Sets the states to indicate whether the RTSP filter will automatically handle persisting Real Networks tunneled RTSP over HTTP, over the RTSP port. The default value is enabled. Disabling this value allows the user to override the default behavior with a rule. | def set_rtsp_over_http_persistence_state(opts)
opts = check_params(opts,[:states])
super(opts)
end | [
"def SetLoggingSettings(rule, state)\n SetModified()\n\n if rule == \"ACCEPT\"\n if state == \"ALL\"\n Ops.set(@SETTINGS, \"FW_LOG_ACCEPT_CRIT\", \"yes\")\n Ops.set(@SETTINGS, \"FW_LOG_ACCEPT_ALL\", \"yes\")\n elsif state == \"CRIT\"\n Ops.set(@SETTINGS, \"FW_LOG_A... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
The RTSP specification allows a control connection to be resumed after it has become disconnected. This sets the states to indicate whether the RTSP filter will persist the control connection that is being resumed to the correct server. | def set_session_reconnect_state(opts)
opts = check_params(opts,[:states])
super(opts)
end | [
"def resume\n\t\t@state = STATE_ONLINE\n\tend",
"def set_rtsp_over_http_persistence_state(opts)\n opts = check_params(opts,[:states])\n super(opts)\n end",
"def setReconnected\n @reconnected = true\n end",
"def resume\n retry_until_true(1) do\n if @state == :paused\n ... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Sets the states to indicate whether to allow redirection of unicasts for this RTSP profile. If enabled, the client is allowed to select the destination where data will be streamed. | def set_unicast_redirect_state(opts)
opts = check_params(opts,[:states])
super(opts)
end | [
"def set_multicast_redirect_state(opts)\n opts = check_params(opts,[:states])\n super(opts)\n end",
"def unicast_redirect_state\n super\n end",
"def multicast_redirect_state\n super\n end",
"def allow_redirect=(value)\n @allow_redirect = value\n end",
"... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
This should probably be moved to the data_entries helper Based on the display type, returns the arguments for the formhelper methods | def prepare_form_helpers
if display_type == "text_field"
return ["data_fields", id, {id: id}]
elsif display_type == "text_area"
return ["data_fields", id]
elsif display_type == "select"
options = values.split(',').each{|opt| opt.squish!}
return ["data_fields", id, options.map{|opt| [... | [
"def prepare_form_helpers\n if display_type == \"text_field\"\n return [\"data_fields\", id, {:id => id}]\n elsif display_type == \"text_area\"\n return [\"data_fields\", id]\n elsif display_type == \"select\"\n options = values.split(',').each{|opt| opt.squish!}\n return [\"data_fields... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
run each match rule to find the group for the resource, or return 'other' group if not found | def calc_group
GROUP_MAPPINGS.keys.each do |group_id|
# return the details, and include the id for reference
return group_details(group_id) if self.in_group?(group_id)
end
# default: return 'other'
return group_details('other')
end | [
"def retrieve_remote_group\n self.each_security_group do |sg|\n sg.rules.map do |rule|\n next if rule.group.nil? || rule.group == rule.parent_group_name\n rule.group = self.find_by(:name, sg.name)\n end\n end\n end",
"def default_rule &blk\n raise BadDefaultRule.new... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
returns true if the resource matches any of the rules for a given group | def in_group?(group_id)
group_details = GROUP_MAPPINGS[group_id]
raise "Group not found" if group_details.nil?
group_details[MATCH_RULES].each do |rule|
matched = self.type.match(rule)
return true if matched
end
return false
end | [
"def secgroup_rule_exists(secgroup)\n rule_set = []\n secgroup_id = lookup_security_group_id(secgroup)\n if secgroup_id.nil?\n return false\n end\n\n # I could find no good means of checking existence without checking every\n # component of every rule. To work around this, I ... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Function: timeofday_greet Description: Gives a time of dayspecific response to a greeting. i.e. 'good morning'. | def timeofday_greet(m)
return unless m.message =~ /\b(good)? ?(morning|afternoon|evening|night),? #{m.bot.nick}\b/i
m.reply "Good #{Regexp.last_match(2).downcase}, #{m.user.nick}!"
end | [
"def timeofday_greet(m)\n if m.message =~ /\\b(good)? ?(morning|afternoon|evening|night),? #{m.bot.nick}\\b/i\n m.reply \"Good #{$2.downcase}, #{m.user.nick}!\"\n end\n end",
"def time_greetings\n if 5 <= Time.now.hour && Time.now.hour <= 12 \n puts \"good morning!\"\n els... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Rewrites a Sexp using :newline nodes to fill in line and file information. | def rewrite exp
unless exp.nil?
if exp.sexp_type == :newline
@line = exp[1]
@file = exp[2]
end
exp.file ||= @file
exp.line ||= @line
end
super exp
end | [
"def rewrite_newline(exp)\n # New lines look like:\n # s(:newline, 21, \"test/sample.rb\", s(:call, nil, :private, s(:arglist)) )\n sexp = exp[3]\n rewrite(sexp)\n end",
"def add_line_info(line, node)\n return if node.is_a?(Expressions)\n return unless node.is_a?(Expression) ||... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Removes newlines from the expression, they are read inside of rewrite, and used to give the other nodes a line number and file. | def rewrite_newline(exp)
# New lines look like:
# s(:newline, 21, "test/sample.rb", s(:call, nil, :private, s(:arglist)) )
sexp = exp[3]
rewrite(sexp)
end | [
"def remove_new_lines(expression)\n expression.gsub(/\\R+/, '')\n end",
"def remove_mid_expression_newlines\n scan_tokens do |prev, token, post, i|\n next 1 unless post && EXPRESSION_CLOSE.include?(post[0]) && token[0] == \"\\n\"\n @tokens.delete_at(i)\n next 0\n ... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Encode body based on content type | def encode_body(body, content_type)
if content_type == 'application/json'
dump_json(body)
else
body
end
end | [
"def encode_body(body, content_type)\n if content_type =~ JSON_REGEX # vnd.api+json should pass as json\n dump_json(body)\n elsif content_type == CONTENT_URLENCODED && body.kind_of?(Hash)\n URI.encode_www_form(body)\n else\n body\n end\n end",
"def encoded_body\n ret... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Method role allows user to input what the monster does | def role
puts "Now give #{@name} a role"
@role = gets.chomp.upcase
puts "The Gods are considering your request, please wait 3 seconds"
sleep 3
puts "The Gods have heard you and #{@name} shall be a: #{@role}"
end | [
"def role; end",
"def select_the_player_role\n output = nil\n # input validation\n until %w[maker breaker].include?(output)\n puts 'Do you want to be a [maker] or a [breaker]?'\n output = gets.chomp\n end\n output\n end",
"def accept_role role\n self.roles.push role\n end",
"def ... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Method age gives monsters an age which is randomly assigned Outputs an integer Output uses conditional to determine next string for output | def age
puts "Now the Gods are assigning a power to #{@name}. This is up to the Gods alone."
sleep 3
@age = rand(10..100)
puts "Attention!!!"
puts "The Gods have given #{@name} the age of #{@age}, and the Gods have willed that age shall determine strength. A power of 1 is no more powerful than a ... | [
"def age()\n age = rand(20..200)\n puts \"Teddy is #{age} years old!\"\nend",
"def guess_age()\n return rand(17..20)\n end",
"def display_teddys_name\r\n age = rand(20..200)\r\n puts \"Teddy is #{age} years old!\"\r\nend",
"def ageist age\n if age <= 1\n status = \"baby\"\n elsif (1..10) === age\... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Power method gives user a choice to give their monster more powers. Computer slects from 4 opposing possibilities in array if Y If N then puts else string This is where game could increment and give user a fixed number of terms Alternatively two monsters could be created who would then battle. | def power
puts "Do you want to request the Gods assign #{@name} some special power?"
puts "Warning!!! The Gods may spite you for asking for too much: Y or N?"
@power = gets.chomp
if @power == "Y"
@power = ["a seer", "as dumb as a cow", "as strong as an ox",
"as fragile as a bird"].samp... | [
"def powm\n probNum = 1\n numTurns = 15\n probDenom = (2..numTurns+1).inject(&:*)\n probPuller = Array.new(numTurns) {|i| i + 1}\n (1..(numTurns-1)/2).each do |i|\n probPuller.combination(i) do |f|\n probNum += f.inject(&:*)\n end\n end\n probDenom / probNum\nend",
"def generate_hero_power_level... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Returns the status or pattern of percolator for this class. | def percolator
@_percolator
end | [
"def pattern\n return @pattern\n end",
"def remediation_status\n return @remediation_status\n end",
"def remediation_status_details\n return @remediation_status_details\n end",
"def klass_matcher\n super do |d|\n ... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Adds ourselves to the ownership list. The last one in the list may access the input through interruptible_region(). | def __with_ownership(&block)
@mutex.synchronize do
# Three cases:
# 1) There are no owners, in this case we are good to go.
# 2) The current owner of the input is not reading the input (it might
# just be evaluating some ruby that the user typed).
# The current owner ... | [
"def add_owner(added_owner)\n if @owners[0] == nil\n @owners = [added_owner]\n else\n @owners << added_owner\n end\n end",
"def addOwner(user)\n @Owners.push(user) \n end",
"def add_owner(task, new_owner)\n self_owned << task if task.self_owned?\n ... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
POST /rodzaj_pracownikas POST /rodzaj_pracownikas.json | def create
@rodzaj_pracownika = RodzajPracownika.new(rodzaj_pracownika_params)
respond_to do |format|
if @rodzaj_pracownika.save
format.html { redirect_to @rodzaj_pracownika, notice: 'Rodzaj pracownika was successfully created.' }
format.json { render :show, status: :created, location: @r... | [
"def create\n @prueba_json = PruebaJson.new(prueba_json_params)\n\n respond_to do |format|\n if @prueba_json.save\n format.html { redirect_to @prueba_json, notice: 'Prueba json was successfully created.' }\n format.json { render action: 'show', status: :created, location: @prueba_json }\n ... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
GET /c_likes GET /c_likes.json | def index
@c_likes = CLike.all
if params[:comment_id].present?
like = CLike.find_by(user_id: current_user.id, comment_id: params[:comment_id])
render json: {status: 'success', like: like, counts: CLike.where(comment_id: params[:comment_id]).count, liked: like.present?}
end
end | [
"def index\n @likes = Like.all\n render json: @likes, status: 200\n end",
"def index\n @likes = Like.all\n render json: @likes\n end",
"def index\n @api_v1_likes = Api::V1::Like.all\n end",
"def get_user_likes\n @likes_hash ||= self.facebook.get_connections(\"me\", \"likes\", {l... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
def valid_begin_date? if effective_beg_date.present? if effective_beg_date < Date.civil(1900,1,1) errors.add(:effective_beg_date, "must be after 1900.") return false else return true end else return true end end | def valid_end_date?
if effective_end_date.present?
if effective_end_date < Date.civil(1900,1,1)
errors.add(:effective_end_date, "must be after 1900.")
return false
else
return true
end
else
return true
end
end | [
"def start_date_is_valid?\n begin\n date = USDateParse(self.start_date)\n self.start_date = date.strftime(\"%m/%d/%y\")\n rescue\n return false\n end\n return true\n end",
"def start_date_is_valid?\n begin\n date = USDateParse(self.start_date)\n rescue\n return false\n ... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
mark cell on board with some token. mutative. does bounds checking and "is this spot taken" checking | def mark!(row, col, player)
return false if invalid_indices(row, col) || !@m[row][col].nil?
@m[row][col] = player.to_s
true
end | [
"def mark symbol, row, column \r\n \traise \"Square #{row}, #{column} is already taken.\" if marked? row, column\r\n @grid[row][column] = symbol\r\n end",
"def mark_at(column, row)\n @board[column][row]\n end",
"def mark(x, y, marker)\t\n @board[x][y] = marker \n\tend",
"def mark(position, lett... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
heuristic for a player winning the game given this board | def heuristic_for_player(player)
# for each row, col, diag:
# +100 for a win, 10 for two (with 1 empty), 1 for single (with 2 empty)
# above negated for other player, subtracting 1/10th because it is not their turn (assume it is player's turn)
# , summed
heuristic_proc = proc do |acc, row|
... | [
"def evaluate_board_for_results\n player1_move_positions = self.moves_by_player[:player1].map{|move| [move.row, move.column]}\n player2_move_positions = self.moves_by_player[:player2].map{|move| [move.row, move.column]}\n if Game.winner_combinations.any?{|streak| streak.all?{|position| player1_move_positio... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
This method creates a file which contains the Solr user credentials for the recipes and monitor scripts to use We also store the app user credentials although we do not need it and do not use it for our purposes This could be useful further down the line to migrate to secreteclient OneOps component | def create_secrete_file()
payload = {
"admin_user" => {
"username" => @solr_admin_user,
"password" => @solr_admin_password,
},
#TODO should the key be "app_user"
@solr_app_user => {
"username" => @solr_app_user,
"password" => @solr_pas... | [
"def setup_credentials\n\n cmd = @config[:path] + @command_line_tool + \" \" + @@login_command\n\n Open3.popen3( cmd ) { |input, output, error|\n input.puts @config[:url]\n input.puts @config[:user]\n input.puts @config[:password]\n input.close\n } ... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
This method uploads the security.json file content to the zookeeper. It just uploads the default template file with no users, roles, permissions added to it | def upload_security_json_with_no_credentials()
payload = {
"authentication" => {
"class" => "solr.BasicAuthPlugin"
},
"authorization" => {
"class" => "solr.RuleBasedAuthorizationPlugin"
}
}
cmd = "#{@solr_install_dir}/server/scripts/cloud-scripts/zk... | [
"def create_secrete_file()\n\n payload = {\n \"admin_user\" => {\n \"username\" => @solr_admin_user,\n \"password\" => @solr_admin_password,\n },\n #TODO should the key be \"app_user\"\n @solr_app_user => {\n \"username\" => @solr_app_user,\n ... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
This method builds the payload for uploading permissions assigned to the to the admin and app roles. The admin role will be assigned to the solr admin user and the app role will be assigned to the solr app user The Solr app user will be able to perform all the admin/regular read operations on the user, he will also be ... | def build_perms_payload()
permissions = [
{"name" => "update", "role" => ["admin","app"]},
{"name" => "read", "role" => ["admin","app"]},
{"name" => "schema-read", "role" => ["admin", "app"]},
{"name" => "config-read", "role" =>["admin","app"]},
{"name" => "collection-admin-r... | [
"def gen_permissions\n\t\tif current_user\n\t\t\t@permissions = {}\n\t\t\t@@PERMISSIONS.each do |permission, roles|\n\t\t\t\t@permissions[permission] = roles[current_user.role_id.to_sym]\n\t\t\tend\n\t\tend\n\tend",
"def build\n if roles.empty?\n debug \"Not building any RolePermit\"\n ... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Snippet for the list_mute_configs call in the SecurityCenter service This is an autogenerated example demonstrating basic usage of Google::Cloud::SecurityCenter::V1::SecurityCenter::Clientlist_mute_configs. It may require modification in order to execute successfully. | def list_mute_configs
# Create a client object. The client can be reused for multiple calls.
client = Google::Cloud::SecurityCenter::V1::SecurityCenter::Client.new
# Create a request. To set request fields, pass in keyword arguments.
request = Google::Cloud::SecurityCenter::V1::ListMuteConfigsRequest.new
# ... | [
"def list_kms_configs request_pb, options = nil\n raise ::ArgumentError, \"request must be provided\" if request_pb.nil?\n\n verb, uri, query_string_params, body = ServiceStub.transcode_list_kms_configs_request request_pb\n query_string_params = if query_string_params.an... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Get Sending Confirmation Email Id. | def confirmation_email_id
@api.get("#{@api.path}/Import/#{@id}/Sending")
end | [
"def confirmed_email\n return unless identity = self.identity(:confirmed)\n identity.email\n end",
"def confirmationMessage\n ActsAsIcontact::Message.find(confirmationMessageId) if properties[\"confirmationMessageId\"]\n end",
"def confirmed_notification_email_to\n send_message_to = EmailServi... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
GET /medecins GET /medecins.json | def index
@medecins = Medecin.all
end | [
"def meme\n fetch('jera.memes')\n end",
"def show\n @messege = Messege.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @messege }\n end\n end",
"def index\n @medicaments = Medicament.all\n\n render json: @m... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
POST /medecins POST /medecins.json | def create
@medecin = Medecin.new(medecin_params)
respond_to do |format|
if @medecin.save
format.html { redirect_to @medecin, notice: 'Medecin was successfully created.' }
format.json { render :show, status: :created, location: @medecin }
else
format.html { render :new }
... | [
"def create\n @medecin = Medecin.new(params[:medecin])\n\n respond_to do |format|\n if @medecin.save\n flash[:notice] = 'Medecin was successfully created.'\n format.html { redirect_to(@medecin) }\n format.xml { render :xml => @medecin, :status => :created, :location => @medecin }\n ... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
PATCH/PUT /medecins/1 PATCH/PUT /medecins/1.json | def update
respond_to do |format|
if @medecin.update(medecin_params)
format.html { redirect_to @medecin, notice: 'Medecin was successfully updated.' }
format.json { render :show, status: :ok, location: @medecin }
else
format.html { render :edit }
format.json { render json... | [
"def update\n @meme = Meme.find(params[:id])\n\n respond_to do |format|\n if @meme.update_attributes(params[:meme])\n format.html { redirect_to @meme, notice: 'Meme was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Movie objects are equal if and only if their id, type, name, votes, duration, rating, release_date, genres and plot attributes are the same. | def ==(other)
[:id, :type, :name, :votes, :duration, :rating, :release_date, :genres, :plot, :under_development].all? do |m|
other.respond_to?(m) && self.public_send(m) == other.public_send(m)
end
end | [
"def eql?(other)\n return true if equal?(other)\n return false unless self == other\n [:id, :fide_id, :rating, :fide_rating, :title, :gender].each do |m|\n return false if self.send(m) && other.send(m) && self.send(m) != other.send(m)\n end\n true\n end",
"def ==(other_movie_sou... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Which user field should be used for the facebook access token? Default: :facebook_access_token Accepts: Symbol | def facebook_access_token_field(value=nil)
rw_config(:facebook_access_token_field, value, :facebook_access_token)
end | [
"def access_token_param_for_user(user)\n \"access_token=#{user.token}\"\n end",
"def access_or_user_token\n if access_token&.token\n access_token\n elsif user_token\n user_token\n else\n access_token\n end\n end",
"def user_token\n acces... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Which User attr_writer should be used for facebook username (if one exists) for a new user when facebook_auto_register is enabled? Default: :facebook_username Accepts: Symbol | def facebook_username_field(value=nil)
rw_config(:facebook_username_field, value, :facebook_username)
end | [
"def new_username=(value)\n @new_username = (value.nil? ? value : value.upcase)\n end",
"def set_username\n unless self.token.nil?\n @graph = Koala::Facebook::API.new(self.token)\n @data = @graph.get_object('me')\n if @data['username'].nil?\n @username = self.email.gsub(\"@\", \"_\").... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
GET /plantypes/1 GET /plantypes/1.json | def show
@plantype = Plantype.find(params[:id])
respond_to do |format|
format.html # show.html.erb
format.json { render json: @plantype }
end
end | [
"def index\n @plan_types = PlanType.page(params[:page])\n\n respond_with(@plan_types)\n end",
"def plans(type)\n validate_server_type(type) do\n perform_request(:action => 'listplans', :type => type)\n parse_returned_params_as_list('plans')\n end\n end",
"def plans(type)\n ... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
GET /plantypes/new GET /plantypes/new.json | def new
@plantype = Plantype.new
respond_to do |format|
format.html # new.html.erb
format.json { render json: @plantype }
end
end | [
"def new\n @tipo_plan = TipoPlan.new\n @accion = 'create'\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @tipo_plan }\n end\n end",
"def create\n @plantype = Plantype.new(params[:plantype])\n\n respond_to do |format|\n if @plantype.save\n ... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
POST /plantypes POST /plantypes.json | def create
@plantype = Plantype.new(params[:plantype])
respond_to do |format|
if @plantype.save
format.html { redirect_to @plantype, notice: 'Plantype was successfully created.' }
format.json { render json: @plantype, status: :created, location: @plantype }
else
format.html ... | [
"def create\n @plan_type = PlanType.new(plan_type_params)\n\n if @plan_type.save\n respond_with(@plan_type, location: plan_types_url, notice: 'Plan type was successfully created.')\n else\n respond_with(@plan_type)\n end\n end",
"def new\n @plantype = Plantype.new\n respond_to do |for... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
PUT /plantypes/1 PUT /plantypes/1.json | def update
@plantype = Plantype.find(params[:id])
respond_to do |format|
if @plantype.update_attributes(params[:plantype])
format.html { redirect_to @plantype, notice: 'Plantype was successfully updated.' }
format.json { head :no_content }
else
format.html { render action: "... | [
"def update\n if @plan_type.update(plan_type_params)\n respond_with(@plan_type, location: plan_types_url, notice: 'Plan type was successfully updated.')\n else\n respond_with(@plan_type)\n end\n end",
"def update\n respond_to do |format|\n if @tipo_plan.update(tipo_plan_params)\n ... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
DELETE /plantypes/1 DELETE /plantypes/1.json | def destroy
@plantype = Plantype.find(params[:id])
@plantype.destroy
respond_to do |format|
format.html { redirect_to plantypes_url }
format.json { head :no_content }
end
end | [
"def destroy\n @plan_type.destroy\n\n respond_with(@plan_type, location: plan_types_url)\n end",
"def destroy\n @tipo_plan = TipoPlan.find(params[:id])\n @tipo_plan.destroy\n\n respond_to do |format|\n format.html { redirect_to tipo_plan_index_path }\n format.json { head :ok }\n end\n... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
num The Integer to be checked. Examples is_odd(1337) => true is_odd(420) => false Returns if the number is odd or not. | def is_odd(num)
return num % 2 == 1
end | [
"def is_odd(num)\n\n if num % 2 == 1\n return true\n end\n \n return false\nend",
"def is_odd(num)\n output = false\n if num % 2 != 0\n output = true\n end\n return output\nend",
"def is_odd?(num)\n num.remainder(2) != 0\nend",
"def is_odd?(number)\n if ... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Whether any implicit routing parameters are present. | def routing_params?
routing_params.any?
end | [
"def routing_params?\n explicit_params? || implicit_params?\n end",
"def implicit_params?\n @http.routing_params?\n end",
"def routing_params?\n routing_params.any?\n end",
"def explicit_annotation?\n !@routing.nil?\n end",
"def any_empty_r... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
The implicit routing parameter names. | def routing_params
routing_params_with_patterns.map { |param, _| param }
end | [
"def param_names\n\t\treturn self.constraints.keys.map( &:to_s ).sort\n\tend",
"def implicit_params\n return {} unless implicit_params?\n @http.routing_params\n end",
"def pnames\n @params.keys\n end",
"def named_routes\n @named_routes.keys\n end",
"def a... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Whether any routing params are present | def routing_params?
routing_params.any?
end | [
"def routing_params?\n routing_params.any?\n end",
"def routing_params?\n explicit_params? || implicit_params?\n end",
"def implicit_params?\n @http.routing_params?\n end",
"def any_empty_routing?\n self.empty?(self, \"routings\", false)\n end",
"def param... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
The combination of verb and path found in the http annotation (or Nil if the annotation is Nil). | def verb_path
return nil if @binding.nil?
{
get: @binding.get,
post: @binding.post,
put: @binding.put,
patch: @binding.patch,
delete: @binding.delete
}.find { |_, value| !value.empty? }
end | [
"def get_verb_and_path request\n\tinitial, headers = initial_headers_split request\n\tverb, path = initial.split(\" \")[0..1]\nend",
"def http_verb(params)\n [:post, :put, :delete].detect { |method_name|\n params.key?(method_name)\n } || :get\n end",
"def path ; @request.path_info ; ... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Parses http bindings from the `google.api.http` annotation, preserving order. | def parse_bindings http
return [] if http.nil?
raw_binds = [http] + http.additional_bindings.to_a
raw_binds.map { |raw_bind| HttpBinding.new raw_bind }
end | [
"def parse_http http_yaml\n http = Google::Api::Http.new\n\n if http_yaml.key? HTTP_RULES_KEY\n http.rules = http_yaml[HTTP_RULES_KEY].map { |rule_yaml| parse_http_rule rule_yaml }\n end\n\n http\n end",
"def test_parse_service_yaml_with_api_http\n api1_nam... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
para la ingresar en la tabla intermedia de muchos a muchos define una propiedad que se puede leer y escribir la llamaremos :category_elements | def save_categories #metodo para registrar en la tabla intermedia muchos a muchos
return category_articles.destroy_all if category_elements.nil? || category_elements.empty?
category_articles.where.not(category_id: category_elements).destroy_all
#si no viene como arreglo----... | [
"def element_subcategory; end",
"def data_elements_with_category_combos(data_elements, limit_to_coc_with_id: nil)\n category_combo_ids = data_elements.map(&:category_combo__id).uniq\n category_combo_by_id = find(category_combo_ids,\n kind: \"category_combos\",\n ... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.