query stringlengths 7 9.5k | document stringlengths 10 1.07M | negatives listlengths 19 19 | metadata dict |
|---|---|---|---|
Build Apartments using their description and features. Get HTML, then parse it and collect parameters. | def build(apartment_url)
@apartment = Nokogiri::HTML(Net::HTTP.get(URI(apartment_url)))
description = apartment_description
features = apartment_features
description['apartment_features'] = features
Apartments.new(description)
end | [
"def create_digest(html)\n apartments = []\n items = html.css('p.row')\n items.each do |item|\n details = item.css('.pl').text\n new_digest = {\n :description => item.css('a').text,\n :price => parse_price(item.css('.price').text),\n :bedrooms => parse_bedrooms(item.css('.pnr').text)\n }\... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Makes common apartments description. Hash, based on constant APARTMENT_DESCRIPTION, first merge it, then find unique description | def apartment_description
apartment_description = {}
apartment_description.merge!(APARTMENT_DESCRIPTION)
apartment_description.keys.each { |key| apartment_description[key] = send(apartment_description[key]) }
apartment_description
end | [
"def duplicateDescriptionUpdate(combinedData)\n #\t\n\t# Items that have duplicate descriptions should be flagged for manual follow-up.\n\t# N^2 sized comparison. \n #\n\n\tcombinedData.each do |entry|\n\t\tcombinedData.each do |record|\n\t\t\tif entry[:itemDesc] == record[:itemDesc]\n\t\t\t\tentry[:descriptionFr... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Makes common apartments features. Hash, based on constant APARTMENT_FEATURES, first merge it, then find unique features | def apartment_features
apartment_features = {}
apartment_features.merge!(APARTMENT_FEATURES)
features_unavailable.each { |feature| apartment_features[feature] = false }
apartment_features
end | [
"def common_landscape_features\r\n # Collect count of each landscape feature from hikes in region\r\n feature_list = {}\r\n not_landscape = [\"Dogs allowed on leash\", \"Dogs not allowed\", \"Established campsites\", \"Good for kids\", \"Fall foliage\"]\r\n\r\n @hikes.each do |hike|\r\n hike.featur... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Courses related to the Cluster | def courses
@courses ||= CourseList.new(:cluster => slug.gsub('-', ' ')).
sort_by { |c| c.title + c.edition }.
uniq { |c| c.code + c.edition }
end | [
"def getClusters(courseId)\n @clusters = []\n CourseCluster.where(course_id: courseId).find_each do |cc|\n Cluster.where(id: cc.cluster_id).find_each do |c|\n @clusters.push(c)\n end\n end\n \n return @clusters\n end",
"def all_courses\n courses = self.courses.to_a\n self.le... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Store a global content data object as a part of content data keeping service. If type is full flush then content data is saved as it. Otherwise incremental diff of comparison with the latest saved file is calculated and saved. In the later case content data objects containing data regarding added files and removed file... | def add(is_full_flush)
content_data = $local_content_data
return if content_data.empty?
# for the latest content data added to the DB
latest_snapshot = nil
# for instances that were added regarding latest_snapshot
added_cd = nil
# for insrances that were removed regarding late... | [
"def save_data\n save_json_file \"mod_data\", @mod_data\n save_json_file \"part_data\", @part_data\n end",
"def global_data\n @global_data ||= DataStore.new(File.expand_path(\"global_data.json\", home_path))\n end",
"def global_data\n return parent.global_data if parent\n @global_... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
and returns true if the string includes all the letters in the alphabet and false otherwise "the quick brown fox jumps over the lazy dog" | def string_has_all_letters(str)
result = {}
str.each_char do |c|
return true if result.length == 26
if c == " "
next
elsif !result.include?(c)
result[c] = c
end
end
result.length == 26 ? true : false
end | [
"def include_every_alphabet?(word)\n for i in 0..word.length-1\n return false if (check_hash(word[i])==[])\n end\n return true\n end",
"def letters?(word)\n\t\t# Split word and check if each letter is within the range a-z\n\t\tword.split('').each do |letter| # Use each loop as it is slightly better... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Query relation tuples Get all relation tuples that match the query. Only the namespace field is required. | def get_relation_tuples(namespace, opts = {})
data, _status_code, _headers = get_relation_tuples_with_http_info(namespace, opts)
data
end | [
"def get_relation_tuples_with_http_info(namespace, opts = {})\n if @api_client.config.debugging\n @api_client.config.logger.debug 'Calling API: ReadApi.get_relation_tuples ...'\n end\n # verify the required parameter 'namespace' is set\n if @api_client.config.client_side_validation && nam... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Query relation tuples Get all relation tuples that match the query. Only the namespace field is required. | def get_relation_tuples_with_http_info(namespace, opts = {})
if @api_client.config.debugging
@api_client.config.logger.debug 'Calling API: ReadApi.get_relation_tuples ...'
end
# verify the required parameter 'namespace' is set
if @api_client.config.client_side_validation && namespace.nil... | [
"def get_relation_tuples(namespace, opts = {})\n data, _status_code, _headers = get_relation_tuples_with_http_info(namespace, opts)\n data\n end",
"def get_relations(args)\n\t\t\tapi_url = \"#{@base_url}/#{args[:collection]}/#{args[:key]}/relations/#{args[:relation]}\"\n\t\t\tdo_the_get_call( url: ap... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Set the unformatted schema name for the given model / connection class EX: class User 'users_db' User.table_name_prefix => 'users_db.' User.table_name => 'users_db.users' | def schema_name=schema_name
self.table_name_prefix = "#{schema_name}." if schema_name && !schema_name.blank?
self.table_name = "#{self.table_name_prefix}#{self.table_name}" unless self.abstract_class?
end | [
"def set_schema(schema)\n define_class_method(:schema) {schema.to_s.to_sym}\n end",
"def set_table_name!\n self.table_name = model_name.plural\n end",
"def roomer_full_table_name_prefix(schema_name)\n \"#{schema_name.to_s}#{Roomer.schema_seperator}\"\n end",
"def __create_m... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Collects all contained fields. | def all_fields
found_fields = Array.new
self.fields.each do |field|
found_fields << field
found_fields = found_fields + field.all_fields if field.type == 'ObjectField'
end
found_fields
end | [
"def all_fields\n return unless captured_metadata.present?\n return @all_fields if @all_fields\n\n @all_fields = {}\n forms.each do |_k, form|\n @all_fields.merge! form.fields\n end\n\n @all_fields\n end",
"def all_fields\n fields + mandatory_fields\n end",
"def field... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
push counts of c_i^d = k | def push(_d, _i, _k)
abort("invalid push") if @c[_d][_i] != nil
@c[_d][_i] = _k
# push to @Cp
@Cp[_d][_k] += 1
# push to @Ce
vkey = Array.new(@d){|d| 0}
vkey[_d] = _i
begin
ckey = vkey2ckey(vkey)
@Ce[ckey][ @A[vkey] ] += 1
end while (vkey = succ_vkey_d(vkey, _d)) != ni... | [
"def bc2 n, k\n dp = {}\n (0..n).each { |i| dp[i] = Hash.new 0 }\n (0..n).each { |i| dp[i][0] = 1 }\n (0..n).each { |i| dp[i][i] = 1 }\n (1..n).each { |i|\n (1...i).each { |j|\n dp[i][j] = dp[i-1][j-1]+dp[i-1][j]\n }\n }\n dp[n][k]\nend",
"def accum_counts(counts)\n each_byte do |b| count... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
cal log marginal likelihood | def cal_log_ml
lml = 0
# log p(c^d | \alpha)
for d in 0..@d-1
lml += cal_log_Z(@c[d], @a)
end
# log p(A | c, \beta)
@Ce.keys.each do |ckey|
lml += cal_log_Z(@Ce[ckey], @b)
end
lml -= @Ce.size * cal_log_Z(Array.new(@v){|v| 0}, @b)
lml
end | [
"def log_likelihood\n @regression.log_likelihood if @opts[:algorithm] == :mle\n end",
"def _log_likelihood x,y,b \n sum = 0\n x.row_size.times{|i|\n xi = Matrix.rows([x.row(i).to_a.collect{|v| v.to_f}])\n y_val = y[i,0].to_f\n sum += log_likelihood_i ... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Create Portfolio after sign up | def create_portfolio
@user = User.last
@portfolio = Portfolio.new
@user.portfolio = @portfolio
@user.save
@portfolio.save
end | [
"def create_portfolio\n puts \"creating portfolio\"\n return Portfolio.create(user: self)\n end",
"def create\n @portfolio = current_user.portfolios.new(params[:portfolio])\n\n\n respond_to do |format|\n if @portfolio.save\n format.html { redirect_to @portfolio, notice: 'Portfolio was suc... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
GET /schoolclasses/1 GET /schoolclasses/1.json | def show
@schoolclass = Schoolclass.find(params[:id])
respond_to do |format|
format.html # show.html.erb
format.json { render json: @schoolclass }
end
end | [
"def show\n @school_class = SchoolClass.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @school_class }\n end\n end",
"def index\n @my_school = MySchool.find(params[:my_school_id])\n @school_classes = @my_school.school_classes\n en... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
GET /schoolclasses/new GET /schoolclasses/new.json | def new
@schoolclass = Schoolclass.new
respond_to do |format|
format.html # new.html.erb
format.json { render json: @schoolclass }
end
end | [
"def new\n @school_class = SchoolClass.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @school_class }\n end\n end",
"def new\n @school = School.new\n \n respond_to do |format|\n format.html # new.html.erb\n format.json { render json:... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
POST /schoolclasses POST /schoolclasses.json | def create
@schoolclass = Schoolclass.new(params[:schoolclass])
respond_to do |format|
if @schoolclass.save
format.html { redirect_to @schoolclass, notice: 'Schoolclass was successfully created.' }
format.json { render json: @schoolclass, status: :created, location: @schoolclass }
e... | [
"def create\n @school_class = SchoolClass.new(school_class_params)\n\n respond_to do |format|\n if @school_class.save\n format.html { redirect_to school_classes_path, notice: 'School class was successfully created.' }\n format.json { render :show, status: :created, location: @school_class }... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
PUT /schoolclasses/1 PUT /schoolclasses/1.json | def update
@schoolclass = Schoolclass.find(params[:id])
respond_to do |format|
if @schoolclass.update_attributes(params[:schoolclass])
format.html { redirect_to @schoolclass, notice: 'Schoolclass was successfully updated.' }
format.json { head :no_content }
else
format.html ... | [
"def update\n @school_class = SchoolClass.find(params[:id])\n\n respond_to do |format|\n if @school_class.update_attributes(params[:school_class])\n format.html { redirect_to school_classes_url, notice: 'Class was successfully updated.' }\n format.json { head :no_content }\n else\n ... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
DELETE /schoolclasses/1 DELETE /schoolclasses/1.json | def destroy
@schoolclass = Schoolclass.find(params[:id])
@schoolclass.destroy
respond_to do |format|
format.html { redirect_to schoolclasses_url }
format.json { head :no_content }
end
end | [
"def destroy\n @school_class = SchoolClass.find(params[:id])\n @school_class.destroy\n\n respond_to do |format|\n format.html { redirect_to school_classes_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @schoolclass.destroy\n respond_to do |format|\n format.... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
FUNCTIONS SECTION FUNCTION: section_looper PURPOSE: Iterate the process on all sections PARAMETERS: email_body: Get content of the email to generate RETURNS: / | def section_looper(email_body)
section = [:first_section, :second_section, :third_section]
section.each do |section|
type_looper(email_body, section)
end
end | [
"def type_looper(email_body, section)\n type = [:new_features, :improvements, :tasks, :bugs]\n \n type.each do |cType|\n tickets_looper(email_body, section, email_body[section][cType][:type], email_body[section][:file], email_body[section][:statuses], email_body[section][cType][:tickets], email_body... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
FUNCTION: type_looper PURPOSE: Itearate the process on all type of tickets PARAMETERS: email_body: Get content of the email to generate section: Current section to iterate on RETURNS: / | def type_looper(email_body, section)
type = [:new_features, :improvements, :tasks, :bugs]
type.each do |cType|
tickets_looper(email_body, section, email_body[section][cType][:type], email_body[section][:file], email_body[section][:statuses], email_body[section][cType][:tickets], email_body[section]... | [
"def section_looper(email_body)\n section = [:first_section, :second_section, :third_section]\n\n section.each do |section|\n type_looper(email_body, section)\n end\nend",
"def tickets_looper(email_body, section, type, file, statuses, tickets, ticket_details)\n i = 0\n\n File.open(file).read... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
FUNCTION: tickets_looper PURPOSE: Iterate on all lines of sprint files (last and next sprints) PARAMETERS: email_body: Get content of the email to generate section: Current section to iterate on type: ? file: ? statuses: ? tickets: ? ticket_details: ? RETURNS: / | def tickets_looper(email_body, section, type, file, statuses, tickets, ticket_details)
i = 0
File.open(file).readlines.each do |cLine|
# Check if the file has been added
if cLine.include?(type) && statuses.inject(false) { |memo, status| cLine.downcase.include?(status.downcase) || memo }
... | [
"def type_looper(email_body, section)\n type = [:new_features, :improvements, :tasks, :bugs]\n \n type.each do |cType|\n tickets_looper(email_body, section, email_body[section][cType][:type], email_body[section][:file], email_body[section][:statuses], email_body[section][cType][:tickets], email_body... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
FUNCTION: pluralize PURPOSE: Add the pluralize PARAMETERS: word: The word to check if we need to add plural of not nb: Number to identify plural RETURNS: Current string with adjustment on plural word | def pluralize(word, nb)
if (nb > 1)
return "#{word}s"
else
return "#{word}"
end
end | [
"def pluralize(word)\n result = word.to_s.dup\n\n if word.empty? || inflections.uncountables.include?(result.downcase)\n result\n else\n inflections.plurals.each { |(rule, replacement)| break if result.gsub!(rule, replacement) }\n result\n end\n end",
"def pluralize(cou... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
FUNCTION: getfilename PURPOSE: Determine the filename with current date PARAMETERS: / RETURNS: Path of the file to create serving to add all information of the sprint update | def getfilename()
current_time = Time.new.strftime("%Y-%m-%d")
# Create filename
filename = current_time + "_sprint_update_CS.html"
# Create folder with all file of sprint update
foldername = "History"
Dir.mkdir(foldername) unless File.exists?(foldername)
return File.join(".", foldern... | [
"def file_path\n \"#{Time.now.to_f}.#{filename}\"\n end",
"def generate_filename\n # add a timestamp if requested\n name = if @cmd[:timestamp]\n \"updaterepo-#{Time.new.strftime('%y%m%d-%H%M%S')}.log\"\n else\n 'updaterepo.log'\n end\n # l... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Creates an instance of a Cluster class, initialized with defaults or the provided points and/or centroid. Params: :points An array of Point objects that will become the members of the cluster. :centroid A Point object representing the centroid of the cluster. Returns: A Cluster instance. | def initialize(params = {})
self.points = params[:points] || []
self.centroid = params[:centroid] || nil
end | [
"def initialize(centroid, points = [])\n self.centroid = centroid\n self.points = points\n end",
"def initialize(points, clusters_count)\n # Do not mutate original structure\n points = points.dup\n\n if block_given?\n points.map! do |point_obj|\n point_ary = yield(point_ob... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Calculates a range for each dimension such that it covers all coordinates in that dimension for all points in the cluster. Returns: An Array of Range objects, sucn that each range_i covers point.coords_i, for all points. | def dimensional_ranges
points = self.points.map &:coords
points.transpose.map { |d| d.min.to_f..d.max.to_f }
end | [
"def all_coords_in(minmax, coord=[], coords=[])\n if minmax.empty?\n coords << coord\n else\n min, max = minmax[0]\n (min..max).each do |dim_coord|\n all_coords_in(minmax[1..-1], coord + [dim_coord], coords)\n end\n end\n coords\n end",
"def get_cluster_domain_ranges\n d... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Adds the specified Point object to this cluster, removing it from any other clusters first. In the future we may make it possible for a point to belong to more than one Cluster, or for a point to have a fuzzy relationship with clusters. Params: point the Point object that should be added to this cluster. Returns: This ... | def add_point(point)
point.cluster.remove_point point if point.cluster
self.points << point
point.cluster = self
end | [
"def <<(point)\n @points << ensure_point_is_location_object(point)\n @points.uniq!\n self\n end",
"def add_to_point point\n add_to_point! point.dup\n end",
"def add_point(point)\n puts \"adding p: #{point}\" if @debug\n @points << point\n if self.mec && self.mec.center\n unle... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Removes the specified Point object from this cluster. Note that if two points with the same coordinates are members of the cluster, only the one with the same memory address will be removed. (Removal is done by instance equality which is based on the memory address not coordinate equality.) Params: point the Point obje... | def remove_point(point)
self.points.delete point
point.cluster = nil
end | [
"def remove(data_point)\n\n raise IllegalStateException if @buffer.active\n\n removed = nil\n block do\n\n # construct path of interior nodes leading to the leaf node set that contains the point\n # (if one exists)\n internal_path = []\n\n n = read_root_node\n\n whi... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
load_and_authorize_resource GET /game_alphabets GET /game_alphabets.json | def index
@game_alphabets = GameAlphabet.all
end | [
"def gather_alphabets\n \talphabets = helpers.gather_alphabets\n\n render json: {\n data: alphabets\n }\n \t\n end",
"def index\n @alphabets = Alphabet.all\n end",
"def show_letter_choices(game_data)\n \"USED LETTERS: #{game_data.chosen_letters}\"\n end",
"def alphabet\n read_att... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
PATCH/PUT /game_alphabets/1 PATCH/PUT /game_alphabets/1.json | def update
respond_to do |format|
if @game_alphabet.update(game_alphabet_params)
format.html { redirect_to @game_alphabet, notice: 'Game alphabet was successfully updated.' }
format.json { head :no_content }
else
format.html { render action: 'edit' }
format.json { render ... | [
"def update\n respond_to do |format|\n if @alphabet.update(alphabet_params)\n format.html { redirect_to @alphabet, notice: 'Alphabet was successfully updated.' }\n format.json { render :show, status: :ok, location: @alphabet }\n else\n format.html { render :edit }\n format.j... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
DELETE /game_alphabets/1 DELETE /game_alphabets/1.json | def destroy
@game_alphabet.destroy
respond_to do |format|
format.html { redirect_to game_alphabets_url }
format.json { head :no_content }
end
end | [
"def destroy\n @alphabet.destroy\n respond_to do |format|\n format.html { redirect_to alphabets_url, notice: 'Alphabet was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n @letter.destroy\n respond_to do |format|\n format.html { redirect_to ... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
check if user_id is in current conversation | def is_in_conversation?(_user_id)
conversation_members.where(user_id: _user_id).any?
end | [
"def conversation_with?(user)\n if Conversation.between(self.id, user.id).exists?\n return true\n else\n return false\n end\n end",
"def has_user?(user)\r\n conversation_members.where(:user_id => user.id).any?\r\n end",
"def has_active_user?(user)\r\n conversation_members.where(\r\n ... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
check if user_id is admin from current conversation | def is_admin?(_user_id)
conversation_members.admin.where(user_id: _user_id).any?
end | [
"def admin?\n if session[:user_id]\n User.find(session[:user_id]).admin\n else\n false\n end\n end",
"def check_admin?\n current_user.user_id == \"admin\" if current_user.present?\n end",
"def is_admin(message)\n Constants::ADMINS.include?message.from.id\nend",
"def is_admin\n admi... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
add a new participant to the current conversation user_ids: (Array) new participants ID current_user: user who is adding the new participant | def add_participant(_user_ids, _current_user = nil)
update(new_members: _user_ids.is_a?(Array) ? _user_ids : [_user_ids], updated_by: _current_user)
end | [
"def add_participant\n user = self.load_user(params)\n meeting = self.load_meeting(params)\n participant_ids = params[\"participant_ids\"]\n comment = params[\"comment\"].nil? ? \"\" : params[\"comment\"]\n\n if user != nil and meeting != nil and participant_ids.length > 0\n particip... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
check if current conversation is a group conversation | def is_group_conversation?
group_title.present?
end | [
"def groupchat?\n self.type == :groupchat\n end",
"def group?\n @is_group\n end",
"def has_conversation?(conversation)\n conversation.is_participant?(messageable)\n end",
"def group?\n type == :group_id\n end",
"def in_group?(group)\n @groups.include? group\n end",
"def mem... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
add a message sent from Bot | def add_bot_message(message)
messages.notification.create(sender_id: User.bot_id, body: message)
end | [
"def add_message(name, message)\n\t\tend",
"def chat_post(message)\n @api.send(\"chat.post(#{message})\")\n end",
"def post_from_bot(bot, message)\n post('/bots/post', {\n bot_id: extract_id(bot),\n text: message\n })\n end",
"def message(options)\n\t\t@sent_messages <... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
add a message _user_id: sender id | def send_message(_user_id, message, extra_data = {})
messages.create!({sender_id: _user_id, body: message}.merge(extra_data))
end | [
"def user_id=(user_id); @message_impl.setUserId user_id; end",
"def send_message_to(_user, _message, extra_data = {})\n return if _user.id == id # skip send message to self\n Conversation.get_single_conversation(id, _user.id).send_message(id, _message, extra_data)\n end",
"def message_to_at_user(at_user)... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
return cache key unread messages for user member | def get_unread_cache_key_for(_user_id)
"cache-count_pending_messages_for-#{id}-#{(last_activity || Time.current).to_i}-#{_user_id}"
end | [
"def unread_message_count\r\n Rails.cache.fetch(unread_message_count_key, :expires_in => 5.minutes) do\r\n invites_requested_of_me.pending.count + invites.pending.count + unread_messages.count\r\n end\r\n end",
"def unread_messages(user)\n Rails.cache.fetch(\"#{cache_key_with_version}/unread_messag... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
ban a member from current conversation group | def ban_member(_user_id)
unless is_in_conversation?(_user_id)
errors.add(:base, "This user is not member of current group")
return false
end
unless is_group_conversation?
errors.add(:base, "This is not a conversation group")
return false
end
banned_users.create(user_id: _user... | [
"def ban_member\n if @conversation.ban_member(params[:user_id])\n head :ok\n else\n render_error_model @conversation\n end\n end",
"def ban_group\n previa_group = PreviaGroup.find(params[:previa_group_id])\n BanGroupFromUser.call(@user, previa_group)\n\n respond_to do |format|\n ... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
send instant notifications for stop typing | def stop_typing(_user)
PubSub::Publisher.new.publish_for(user_participants.online.where.not(id: _user.id), 'stop_typing', {source: {id: id}, user: {id: _user.id}}, {foreground: true})
end | [
"def stopped_typing\n @omegle.post '/stoppedTyping', \"id=#{@id}\"\n end",
"def typing_off\n payload = {\n recipient: sender,\n sender_action: 'typing_off'\n }\n\n Facebook::Messenger::Bot.deliver(payload, access_token: access_token)\n end",
"def send_... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
create default message after group was created | def generate_welcome_message
if default_message.present?
messages.notification.create(sender_id: owner_id, body: default_message)
else
messages.notification.create(sender_id: owner_id, body: "#{owner.full_name(false)} created this conversation group.") if is_group_conversation?
end
end | [
"def message_1day_after_create_usergroup(group)\n @user = group.user\n return unless @user.receive_notification\n @group = group\n mail to: @user.email, from: 'yaw@loverealm.org', subject: \"Quick Question\"\n end",
"def new_group_chat_message(to)\n self.new_message(to, Jabber::Protocol::Message... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Returns true if the document has code callouts | def has_callouts?
parser = REXML::Parsers::PullParser.new(File.new(@docbook_file))
while parser.has_next?
el = parser.pull
if el.start_element? and (el[0] == "calloutlist" or el[0] == "co")
return true
end
end
return false
end | [
"def contains_code?\n @elements.each { |e| return true if e.instance_of?(Domain::Source) }\n false\n end",
"def code?\n\t\t@ida.isCode(flags)\n\tend",
"def has_source_code_info?\n return files.all? { |f| f.has_source_code_info? }\n end",
"def has_source_code_info?\n file_descriptor_proto... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
calculating VORP comparing runs produced for replacement player vs. selected player, then normalize for 150 game season formula adapted from | def calcVORP(statsArray)
#constants
lgBA = 0.253
lgOBP = 0.317
lgSLG = 0.396
lgRunsPerOut = 0.1633
replaceR = 0.8
replaceRadical = (25 * lgOBP * lgSLG) / (1 - lgBA)
replaceRoot = (replaceRadical ** (1/3.0))
replaceP = (0.1073-(0.11 * replaceR)) * replaceRoot
ab = statsArray[1]
hits = statsAr... | [
"def predict_victory\n @player_service = LolPlayerService.new(@player)\n @team1_winrate = @team2_winrate = @team1_kda = @team2_kda = @team1_skill_points = @team2_skill_points = 0.0\n\n @game_info.participants.each_with_index do |participant, index|\n player = Player.find_by(name: participant.s... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Sets the attribute content_type_db_path | def content_type_db_path=(_arg0); end | [
"def schema_content_path=(content_path)\n @schema_content_path = content_path\n end",
"def database_path=(value)\n self.database.path = value\n end",
"def content_type=(value)\n @content_type = value\n end",
"def content_type=(value)\n @content_type = val... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Returns the value of attribute ext_db_path. source://mini_mime//lib/mini_mime.rb20 | def ext_db_path; end | [
"def ext_db_path=(_arg0); end",
"def content_type_db_path=(_arg0); end",
"def extname\n @path.extname\n end",
"def dbfile\n swish_result_property_str @result, \"swishdbfile\" \n end",
"def extension_path\n end",
"def extension\r\n logger.debug(\"Retreiving extension: #{@file_data.o... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Sets the attribute ext_db_path | def ext_db_path=(_arg0); end | [
"def ext_db_path; end",
"def database_path=(value)\n self.database.path = value\n end",
"def database_path=(newpath)\n db = @opts[\"first_database_name\"]\n newpath = File.join(newpath, _sys_ind_basename(db))\n @opts[\"first_database_name\"] = newpath\n end",
"def default_database_file_path=... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
This will both create and update any merchants | def create_update(user)
merchant_list.each do |m|
# Look for merchants that this affiliate account is actively associated with.
if m['Association_Status'] == 'active'
merchant = do_db(m)
user.merchants << merchant unless user.merchants.include?(merchant)
end
end
end | [
"def merchants\n @merchants ||= MerchantsApi.new config\n end",
"def merchants\n @merchants = policy_scope(Merchant)\n render 'merchants.json.jbuilder', status: :ok\n end",
"def activate_merchants(catalog_key, merchants)\n results = self.class.post(catalog_update_url(catalog_key, mer... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
DELETE /inputs/1 DELETE /inputs/1.json | def destroy
@input.destroy
respond_to do |format|
format.html { redirect_to inputs_url }
format.json { head :no_content }
end
end | [
"def destroy\n @input = Input.find(params[:id])\n @input.destroy\n\n respond_to do |format|\n format.html { redirect_to inputs_url }\n format.json { head :ok }\n end\n end",
"def destroy\n @input = Input.find(params[:id])\n @input.destroy\n\n respond_to do |format|\n format.ht... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Retry block for node.find method above. | def retry_block(n = MAX_NODE_QUERY_RETRIES, &block)
begin
block.call
rescue Selenium::WebDriver::Error::StaleElementReferenceError, Capybara::TimeoutError, Capybara::ElementNotFound, Selenium::WebDriver::Error::UnknownError, Capybara::Driver::Webkit::NodeNotAttachedError
if (n -= 1) >= 0
sleep(30 / (n... | [
"def find_job(job_id)\n tries ||= 5\n @job = Job.uncached { Job.find(job_id) }\n rescue ActiveRecord::RecordNotFound => e\n tries -= 1\n raise e if tries < 1\n\n sleep 0.1\n retry\n end",
"def retry_block_until_true\n (0..RETRY_COUNT).each do\n return if yield\n sleep RETRY_STEP\n... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Generate a "state" key that can be passed to the OAuth endpoints | def oauth_state
org = retrieve_organization
state = "#{org.name}:#{org.salt}:#{org.owner_email}"
Base64.urlsafe_encode64(Digest::SHA256.digest(state))
end | [
"def generate_state_id\n SecureRandom.uuid\n end",
"def gen_api_key\n return \"A key will be generated upon approval.\" unless at_stage?(:confirmed)\n # Start with the datetime of when the user_key was first requested.\n date_string = self.time_submitted.to_s.split(\"\")\n # Get the andrew... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Normalize a Github URL into a Cyclid style source definition | def normalize(url)
uri = URI.parse(url)
source = {}
source['url'] = "#{uri.scheme}://#{uri.host}#{uri.path.gsub(/.git$/, '')}"
source['token'] = uri.user if uri.user
source['branch'] = uri.fragment if uri.fragment
source
e... | [
"def canonicalize_source(source)\n if source.is_a?(Hash) && source[:github]\n source = source.dup\n source[:git] = \"https://github.com/#{source[:github]}.git\"\n source.delete(:github)\n end\n source\n end",
"def shorten(url)\n if url =~ /^https?:\\/\\/(?:www\\.)?github\... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Extract the "humanish" part from a Git repository URL | def humanish(uri)
uri.path.split('/').last.gsub('.git', '')
end | [
"def repository_name(url)\n last_chunk = url.split('/').last\n last_chunk['.git'] = ''\n\n last_chunk\nend",
"def extract_repo_info(url)\n m, username, repo_name = *url.match(/^https?:\\/\\/(?:www.)?github.com\\/([^\\/]+)\\/([^\\/#?]+)/i)\n return (m ? [username, repo_name] : nil)\n end",
... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
=begin As a user, if I select add I am prompted to enter a 'first name', 'last name', 'email' and 'note'. =end | def add_new_contact
puts "\e[H\e[2J"
p "enter firstname"
first_name = gets.chomp
p "enter lastname"
last_name = gets.chomp
p "enter email address"
email = gets.chomp
p "enter note: optional"
note = gets.chomp
contact = Contact.create(
first_name: first_name,
last_na... | [
"def person_prompt\n puts \"We know all the people. Do you want to Add (A), Seach (S), or Delete (D) someone?\"\n gets.chomp\n end",
"def add_patron\n\tputs \"\\nTo add a new patron please enter the following requested information:\\n\"\n\tprint \"Name \"\n\tname = gets.chomp\n\tprint \"Email Address \"\n\... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
GET /rent_images GET /rent_images.json | def index
@rent_images = RentImage.all
end | [
"def index\n @rental_item_images = RentalItemImage.all\n end",
"def images\n response = JSON.parse( self.class.get(\"#{BASE_URL}/contest/#{@api_key}/images\") )\n end",
"def getimagesinfo\n trek = Trek.find_by_id(params[:id])\n send_data(trek.get_images_info.to_json,\n {:type => \... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
DELETE /rent_images/1 DELETE /rent_images/1.json | def destroy
id = @rent_image.rent_id
@rent_image.destroy
respond_to do |format|
format.html { redirect_to "/rents/gallery/"+id.to_s, notice: 'Rent image was successfully destroyed.' }
format.json { head :no_content }
end
end | [
"def delete_floor_plan(args = {}) \n delete(\"/files.json/floorplan/images\", args)\nend",
"def destroy\n @image = Image.find(params[:id])\n @image.destroy\n render json: {status: \"success\"}, status: :ok\n end",
"def delete_image\n if request.post? == false\n render :json => { :message => \"... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
to get the currency object of money | def currency
money.currency
end | [
"def currency\n number_to_currency(self)\n end",
"def currency\n data[:currency]\n end",
"def currency\n account.currency\n end",
"def currency_code\n Money::Currency.new(self.currency).iso_code\n end",
"def to_base_currency(money)\n bank.exchange_with(money, price_currency)\n end",
... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
imperials is the imperials value | def metrics
standard.unit.convert_to_metric imperials
end | [
"def volume(imperial = true)\n if imperial\n returnValue = board_feet.to_s\n else\n returnValue = cubic_meters.to_s\n end\n return returnValue\n end",
"def to_gallon_imperial(**options) = convert_to('gallon-imperial', **options)",
"def in?; measurement == :inches; end",
"def imperial\n\... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
replaces a function with the arguments passed in command: the command to do the substitution in name: the name of the function args: the argument list expression: the expression of the function | def args_replace command, name, args, expression
initial_offset = offset = (command =~ /\b#{Regexp.escape name}\(/) + name.length + 1
bracket_count = 1
# find the last bracket
while offset < command.length
if command[offset] == ?(
bracket_count += 1
elsif command[offset] == ?)
bracket_count... | [
"def replace_string_variant command\n matcher = Regexp.new(\"\\\\#(.+?)\\\\#\")\n\n while match_data = matcher.match(command)\n param_name = match_data.captures.first\n command.sub!(Regexp.new(\"\\\\##{param_name}\\\\#\"), $context[param_name])\n end\n\n matcher = Regexp.new(\"\\\\*(.+?)\\\\*\")\n\n whil... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
This method helps with building options_for_select for an object that has an association to a nested_set model returns options_for_select with the following rules: class_or_item must be a class (or object of a class) that uses acts_as_nested_set items listed in excluded_items array will not be included in the list (to ... | def nested_set_association_options_for_select(class_or_item, excluded_items=[], prompt="Please select..." )
throw ArgumentError.new "nested_set_association_options_for_select - class_or_item must use acts_as_nested_set" unless class_or_item.respond_to?(:roots)
def get_children(node, excluded... | [
"def nested_select(object, method, collection, options = {}, html_options = {})\n choices = nested_as_options(collection) { |record| [\"#{@indent} #{record.name}\", record.id] }\n select(object, method, choices, options, html_options)\n end",
"def items_for_select_menu(options = {}) \n # clean out... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
GET /batches GET /batches.json | def index
@batches = Batch.all
respond_to do |format|
format.html {}
format.json {
data = Hash.new
data["batches"] = @batches
return_success_response(data, "Request Successful", 200)
}
end
end | [
"def query_batches(options={})\n path = \"/api/v2/batches\"\n get(path, options)\n end",
"def query_batches(options={}) path = \"/api/v2/batches\"\n get(path, options, AvaTax::VERSION) end",
"def index\n @batches = Batch.page(params[:page]).per(15)\n @page = params[:p... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Find a note by notebook | def find_note_by_notebook(notebook, sleep = false)
sleep(5) if sleep
title = Formatting.date_templates[notebook]
@model.find_note_contents(title)
end | [
"def find_notebook(name)\n notebooks = self.listNotebooks(@token)\n notebooks.each do |notebook|\n return notebook if notebook.name.eql? name\n end\n return nil\n end",
"def search_note(string)\n logger.info 'Searching for a string within a note'\n search string\n end",
"def find_note(p... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
draw a bar at given column with provided value (this command does not overwrite the screen) | def bar(column, value)
command "B#{column},#{value}"
end | [
"def draw_bar(x,y,p,m,h,c)\n self.contents.fill_rect(x, y - 1, m, h, Color.new(0, 0, 0))\n for i in 0...(h - 2)\n r = c.red * i / (h - 2)\n g = c.green * i / (h - 2)\n b = c.blue * i / (h - 2)\n self.contents.fill_rect(x + 1, y + i, p * (m - 2), 1, Color.new(r, g, b))\n end\n end",
"... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
do an action on a pixel at given column/row | def pixel(column, row, action)
command "P#{column},#{row},#{action.to_s.upcase}"
end | [
"def color_pixel x, y, color\n cell = get_cell(x,y)\n cell.value = color\n end",
"def mark_at(column, row)\n @board[column][row]\n end",
"def update_cell (row_index, col_index, value)\n return if !within?(@image, row_index) || !within?(@image[row_index], col_index)\n @image[row_index][col_index] ... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
scroll to left or right with given offset | def scroll(offset)
command "SCROLL#{offset}"
end | [
"def scroll_right(distance)\n @display_x = [@display_x + distance, (self.width - 20) * 128].min\n end",
"def scroll_to(params)\n begin\n $results.log_action('scrollto')\n @driver.find_element(:id, params[0]).location_once_scrolled_into_view\n $session.success = true\n $results.success\n... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
print a character at given column/row | def char(column, row, char)
command "T#{column},#{row},#{char}"
end | [
"def char_at(column)\n line[column, 1]\n end",
"def position_cursor( row, column )\r\n STDOUT.write \"\\e[#{ row };#{ column }H\"\r\n end",
"def write_char( x, y, c )\n puts \"x-#{x}, y-#{y}, c-#{c}\"\n @board[x][y] = Tile.new(c, \"\")\n end",
"def print_char(b)\n if b == 10\n @... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
which fields will be visible on the index page | def index_fields
if @rails.choice[:index_fields].blank?
@rails.resource.fields.keys
else
@rails.choice[:index_fields].collect{|field| field.split(':').first}
end
end | [
"def index_fields document=nil\n filter_fields blacklight_config.index_fields, document\n end",
"def index_fields document=nil\n blacklight_config.index_fields\n end",
"def index_fields\n self.class.fields.values.select { |field| field.index }\n end",
"def index_fields_for_view view = :list\n ... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
GET /authors/new GET /authors/new.xml | def new
@author = Author.new
respond_to do |format|
format.html # new.html.erb
format.xml { render :xml => @author }
end
end | [
"def new\n @author = Author.new\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @author }\n end\n end",
"def new\n @name_author = NameAuthor.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @name_aut... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
PUT /authors/1 PUT /authors/1.xml | def update
@author = Author.find(params[:id])
respond_to do |format|
if @author.update_attributes(params[:author])
format.html { redirect_to(@author, :notice => 'Author was successfully updated.') }
format.xml { head :ok }
else
format.html { render :action => "edit" }
... | [
"def update_author(id, data)\n #FIXME: Author controller doesnt receive data\n return @client.raw(\"put\", \"/content/authors/#{id}\", nil, data)\n end",
"def update\n @name_author = NameAuthor.find(params[:id])\n\n respond_to do |format|\n if @name_author.update_attributes(params[:nam... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
DELETE /authors/1 DELETE /authors/1.xml | def destroy
@author = Author.find(params[:id])
@author.destroy
respond_to do |format|
format.html { redirect_to(authors_url) }
format.xml { head :ok }
end
end | [
"def destroy\n @author.destroy\n\n respond_to do |format|\n format.html { redirect_to(authors_url) }\n format.xml { head :ok }\n end\n end",
"def destroy\n @author = Author.find_by(url: params[:id])\n @author.destroy\n\n respond_to do |format|\n format.html { redirect_to(authors... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Method moves a card from game cards to specified hand | def deal_card(hand)
#hand is a string whose valid values are 'player_cards' and 'dealer_cards'
if !['player_cards','dealer_cards'].include?(hand)
raise "Unknown hand #{hand}"
end
#Check for an empty deck and reshuffle if necessary
if (session['game_cards'].length == 0)
... | [
"def swap_card_with_hand(card)\n #this_pos_x, card.pos_x = card.pos_x, @hand_card.pos_x\n #this_pos_y, card.pos_y = card.pos_y, @hand_card.pos_y\n @hand_card.pos_x = card.pos_x\n @hand_card.pos_y = card.pos_y\n\n @game_set.delete(card)\n @game_set.push(@hand_card)\n @hand_set.dele... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Totals the points for a hand | def hand_total(hand)
#A flag to see if the hand contains an ace
have_ace = ! ( session[hand].select{|card| card['rank'] == "ace"}.empty? )
total = 0
#Look up the point value of each card in the hand
session[hand].each do |card|
total += RANK_TO_POINTS[ card['rank']]
e... | [
"def calcScore(hand)\n return hand.inject(0) { |sum, n| sum + n.points }\nend",
"def points\n @treasure_chest.values.reduce(0, :+)\n end",
"def total_points_from_lineups_away\n binding.pry\n self.away_team.lineup.collect {|pl| pl.points}.inject{|sum, pts| sum + pts}\n\n\n @away_tea... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
POST /preparar_mates POST /preparar_mates.json | def create
@empresa = Empresa.find(params[:empresa_id])
@producto = @empresa.productos.find(params[:producto_id])
@preparar_mate = @producto.preparar_mates.build(preparar_mate_params)
respond_to do |format|
if @preparar_mate.save
format.html { redirect_to empresa_producto_preparar_... | [
"def create\n @mate = Mate.new(mate_params)\n\n respond_to do |format|\n if @mate.save\n format.html { redirect_to @mate, notice: 'Mate was successfully created.' }\n format.json { render :show, status: :created, location: @mate }\n else\n format.html { render :new }\n fo... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
PATCH/PUT /preparar_mates/1 PATCH/PUT /preparar_mates/1.json | def update
@empresa = Empresa.find(params[:empresa_id])
@producto = @empresa.productos.find(params[:producto_id])
@preparar_mate = @producto.preparar_mates.find(params[:id])
respond_to do |format|
if @preparar_mate.update(preparar_mate_params)
format.html { redirect_to empresa_producto_... | [
"def update\n respond_to do |format|\n if @mate.update(mate_params)\n format.html { redirect_to @mate, notice: 'Mate was successfully updated.' }\n format.json { render :show, status: :ok, location: @mate }\n else\n format.html { render :edit }\n format.json { render json: @... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Retrieve all the tag guids for a provided service entry and tag group | def tag_guids_for_tag_group(service_entry, tag_group)
guids = service_entry['TagGuids']
return [] if guids.blank?
# The first element of the tag strings ARE the tag group. We'll group
# by that value and return the requested group. This saves a fair amount
# of logic from having to be copy and pas... | [
"def tags\n get.tagGuids\n end",
"def get_tagid_by_names tagname, groupname = \"NETWORKTYPE\"\n\t\tselector = {:name => tagname}\n\t\ttaggroup = CmpTaggroup.find_by name: groupname\n\t\tselector[:groupid]= taggroup.id \n\t\ttags = CmpTag.where(selector).all\n\n\t\ttags #[1].id\n\tend",
"def add_tag_re... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Provided a service entry this will pull out concept ids from tag guids and request the collections from CMR | def collections_from_service_entry_tags(service_entry)
concept_ids = concept_ids_from_service_entry_tags(service_entry)
return [] if concept_ids.blank?
response = cmr_client.get_collections_by_post({ concept_id: concept_ids, page_size: concept_ids.size }, token)
if response.success?
response.bod... | [
"def get_datasets_for_service_implementation(params = {})\n # service_interface_guid is not a permitted param for CMR but we need it for this call\n # so we'll use delete to pop the value from the params hash\n response = echo_client.get_service_entries(echo_provider_token, params.delete('service_interface... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Delete the given user configurations. deletions on keys prefixed by 'biapi.' (except callback_url) are ignored keys (string): list of coma separated keys to be deleted. | def users_id_user_config_delete(id_user, opts = {})
users_id_user_config_delete_with_http_info(id_user, opts)
nil
end | [
"def destroy\n @user_config = UserConfig.find(params[:id])\n @user_config.destroy\n\n respond_to do |format|\n format.html { redirect_to user_configs_url }\n format.json { head :no_content }\n end\n end",
"def delete_keys_from_users(key, user)\n debug \"delete_keys_from_users: #{key.in... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Create a recurrence which will only emit values within the date range, also called "masking." | def covering(date_range)
merge(covering: date_range)
end | [
"def recurrent_range_in_date(date)\n raise 'Not recurrent event' unless recurrent?\n\n # Check if it matches the date\n return nil unless in_range?(date)\n\n case @rec['FREQ']\n when 'WEEKLY' then\n return nil unless happen_in_week?(date)\n return nil unless happen_in_day_of_the_week?(date)... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Takes an array of three integers to add to VERSION and three integers to multiply to VERSION | def bump(by,reset)
version_triplet.zip(by, reset).collect{|x,y,z| (x+y)*z}.join(".")
end | [
"def test_bump_numeric\n value_ = ::Versionomy.create([1, 9, 2, 'a2'], :semver)\n value_ = value_.bump(:patch)\n assert_equal([1, 9, 3, ''], value_.values_array)\n end",
"def custom_multiply(array,number)\n new_array = []\n number.times {new_array+=array}\n return new_array\nend... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Returns a key that will be used to group ids into batches. | def group_key(id)
nil
end | [
"def group_key(id)\n nil\n end",
"def batch_key(_record)\n raise \"Implement in child\"\n end",
"def key_map_for_ids(group)\n group.each_with_object({}) do |id, km|\n prefixed_key = \"#{cache_prefix}#{cache_key(id)}\"\n km[prefixed_key] = id\n end\n e... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Public: Returns a curve which describes the demand for electricity caused by the activities within the calculator. | def elec_demand_curve
@elec_demand_curve ||= ElectricityDemandCurve.from_adapters(adapters)
end | [
"def demand_curve\n @demand_curve ||= total_of([\n positive_only_curve(base_curve),\n @consumers,\n @flexibles.map { |flex| negative_only_curve(flex) }\n ].flatten)\n end",
"def demand_curve\n load_curve('demand.csv')\n end",
"def demand_curve\n @demand_curve... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Public: Returns the adapter for the node matching `key` or nil if the node is not a participant in the group. | def adapter(key)
if (config = @context.graph.node(key).fever)
adapters_by_type[config.type].find { |a| a.node.key == key }
end
end | [
"def adapter(key)\n adapters[key]\n end",
"def participant_from(key)\n adapter = @manager.adapters[key.to_s.sub(/_[^_]*$/, '').to_sym]\n if adapter&.participant.is_a?(Array)\n key.end_with?('producer') ? adapter.participant[0] : adapter.participant[1]\n end\n end",
"def node(participant_k... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Internal: Maps Fever types (:consumer, :storage, etc) to adapters. | def adapters_by_type
return @adapters if @adapters
@adapters =
Manager::TYPES.each_with_object({}) do |type, data|
data[type] =
Etsource::Fever.group(@name).keys(type).map do |node_key|
Adapter.adapter_for(
@context.graph.node(node_k... | [
"def adapters\n @adapters ||= {}\n end",
"def adapters\n @adapters ||= {}\n end",
"def adapters\n @adapters ||= {}\n end",
"def adapter(key)\n if (config = @context.graph.node(key).fever)\n adapters_by_type[config.type].find { |a| a.node.key == key }\n end\n ... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
This method looks at the params hash. Its looking for a param that ends in '_id'. Once found it removes the id and then returns the class and the id to look up. For example in the route /learning_paths/:learning_path_id/custom_content the method would find `learning_path_id` and then return the class LearningPath and l... | def resource_class
params.each do |name, _value|
if /(.+)_id$/.match?(name)
model = name.match(%r{([^\/.]*)_id$})
return model[1].classify.constantize, name
end
end
nil
end | [
"def behaveable_class\n params.each do |name, _value|\n if name =~ /(.+)_id$/\n model = name.match(%r{([^\\/.]*)_id$})\n return model[1].classify.constantize, name\n end\n end\n nil\n end",
"def class_param_id(klass)\n klass.self_and_subclass_param_ids.each {|i... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Adds +action_names+ to the list of valid actions for this resource. Does not include superclass's action list when appending. | def actions(*action_names)
action_names = action_names.flatten
if !action_names.empty? && !@allowed_actions
self.allowed_actions = ([ :nothing ] + action_names).uniq
else
allowed_actions(*action_names)
end
end | [
"def with_actions( action_names )\n action_names.each do |action_name|\n action_items << ActionItem.new(name: action_name )\n end\n end",
"def action_in_action_list\n if !action_list.keys.include?(self.action)\n self.errors.add(:action, \"The action must be set to one of the provided value... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Define a method `rec_sum(nums)` that returns the sum of all elements in an array recursively | def rec_sum(nums)
end | [
"def recursive_sum(arr_of_nums)\n return arr_of_nums.last if arr_of_nums[1].nil?\n arr_of_nums.shift + recursive_sum(arr_of_nums)\nend",
"def sum_array_rec(array_to_sum)\n if(array_to_sum.length > 0)\n sum = array_to_sum[0]\n sum += sum_array_rec(array_to_sum[1..-1])\n else\n 0\n end\nend",
"def a... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
GET /certifieds GET /certifieds.json | def index
@certifieds = Certified.where(user: self.current_user)
end | [
"def certified\n @hash[\"Certification\"][\"certified\"]\n end",
"def show\n @candidates_certification = CandidatesCertification.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @candidates_certification }\n end\n end",
"def inde... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
POST /certifieds POST /certifieds.json | def create
@certified = Certified.new(certified_params)
@certified.events = events
@certified.attendees = attendees
@certified.slug = generate_token
@certified.user = self.current_user
flash[:notice] = "Certificado criado com sucesso." if @certified.save
respond_with(@certified) do |format... | [
"def create\n @candidates_certification = CandidatesCertification.new(params[:candidates_certification])\n\n respond_to do |format|\n if @candidates_certification.save\n format.html { redirect_to @candidates_certification, notice: 'Candidates certification was successfully created.' }\n for... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
DELETE /certifieds/1 DELETE /certifieds/1.json | def destroy
@certified.destroy
respond_to do |format|
format.html { redirect_to certifieds_url }
format.json { head :no_content }
end
end | [
"def destroy\n @cert.destroy\n respond_to do |format|\n format.html { redirect_to certs_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @certification.destroy\n\n respond_to do |format|\n format.html { redirect_to certifications_url }\n format.json { head ... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
display all current user computers | def list
user = User.find(current_user.id)
@computers = user.computer.all
end | [
"def index\n @desktop_computers = DesktopComputer.all\n end",
"def index\n @computers_cpus = ComputersCpu.all\n end",
"def computers(params = {})\n params.merge!(key: 'computers')\n objects_from_response(Code42::Computer, :get, 'computer', params)\n end",
"def list_current_user\n ... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
simulate the P2P network i starting origins n peers tr array of [t, r] | def simulate i, n, tr
unless tr[0].is_a?(Numeric) && tr[1].is_a?(Numeric)
require 'pry'
binding.pry
end
er = tr[0].to_f / (n-2)
ps = i.to_f / n
data = {prior_s: ps, prob_ex: er, total_queries: 0, kdist: []}
# every peer (other than origins) might get to do a direct query and/or get extra responses... | [
"def simulate i, n, t\n er = t.to_f / (n-2)\n ps = i.to_f / n\n data = {prior_s: ps, prob_ex: er, total_queries: 0, kdist: []}\n\n # every peer (other than origins) might get to do a direct query and/or get extra responses\n know = Array.new(n - i) { false }\n data[:responses] = []\n\n k = i\n j = 0\n whil... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
GET /drawings/1 GET /drawings/1.json | def show
@drawing = Drawing.find(params[:id])
render json: @drawing
end | [
"def index\n @drawings = Drawing.all\n \n respond_to do |format|\n format.html # index.html.erb\n format.json { render :json => @drawings }\n end\n end",
"def show\n @drawing = Drawing.find(params[:id])\n \n respond_to do |format|\n format.html # show.html.erb\n ... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
GET /drawings/new GET /drawings/new.json | def new
@drawing = Drawing.new
render json: @drawing
end | [
"def new\n @drawing = Drawing.new\n \n respond_to do |format|\n format.html # new.html.erb\n format.json { render :json => @drawing }\n end\n end",
"def new\n @drawing = Drawing.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
POST /drawings POST /drawings.json | def create
@drawing = Drawing.new(params[:drawing])
if @drawing.save
render json: @drawing, status: :created, location: @drawing
else
render json: @drawing.errors, status: :unprocessable_entity
end
end | [
"def create\n @user_banks = current_user.user_banks.green\n @drawing = current_user.drawing(drawing_params.to_h)\n respond_to do |format|\n if @drawing.user_bank.errors.empty? && @drawing.errors.empty?\n format.html { redirect_to my_drawings_url, notice: t(:drawing_success) }\n ... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
PATCH/PUT /drawings/1 PATCH/PUT /drawings/1.json | def update
@drawing = Drawing.find(params[:id])
if @drawing.update_attributes(params[:drawing])
head :no_content
else
render json: @drawing.errors, status: :unprocessable_entity
end
end | [
"def update\n @drawing = Drawing.find(params[:id])\n\n respond_to do |format|\n if @drawing.update_attributes(params[:drawing])\n format.html { redirect_to @drawing, notice: 'Drawing was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render ac... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Resolves the given relative path of file in repository into canonical path based on the specified base_path. Examples: File in the same directory as the current path resolve_relative_path("users.adoc", "doc/api/README.adoc") => "doc/api/users.adoc" File in the same directory, which is also the current path resolve_rela... | def resolve_relative_path(path, base_path)
p = Pathname(base_path)
p = p.dirname unless p.extname.empty?
p += path
p.cleanpath.to_s
end | [
"def resolve_relative_and_full_path(relative_path)\n relative_path =~ /^\\// ? find_relative_and_full_path(relative_path) : [relative_path, find_full_path(relative_path)]\n end",
"def relative_from_base(path)\n Pathname.new(@from_base).relative_path_from(Pathname.new(path)).to_s\n end",
"def... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Generalized tick fetch. If the block is used, the arrays will be retured in chunks, which should be accumulated. This is to eliminate the problem of passing large arrays across DRb. | def fetchTicks(symbol, days=nil, startTime=nil, endTime=nil, eos=true, &block)
brokerFetchTicks(symbol, days, startTime, endTime, eos, &block)
end | [
"def handle_tick_internal\n create_deferred_result\n end",
"def block ( ds, de, rs )\n size = de - ds\n off = rs - ds\n printf( \"Block: %08x to %08x %d\\n\", rs, rs+size, off )\n x = Array.new\n x[0] = rs\n x[1] = rs + size\n x[2] = off\n $bdata << x\nend",
"def perform_tick\n ... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Returns HTML with all authors of an article | def display_article_authors(article, with_info=false)
authors = article.authors.map{|author| author.gplus_profile.blank? ? author.name : link_to(author.name, author.gplus_profile)}.to_sentence(two_words_connector: " & ", last_word_connector: " & ").html_safe
if with_info
authors += (" — " + article.... | [
"def show_all_article_titles_with_authors\n @all = all_article_titles_with_authors\n @all.each do |title, author|\n puts \"#{author} - #{title}\"\n end\n return @all\n end",
"def show_all_authors\n @all = []\n search_techcrunch[\"articles\"].each do |article|\n @all << article[\"autho... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
POST /cyclists POST /cyclists.json | def create
@cyclist = Cyclist.new(cyclist_params)
@cyclist.shift_id = params["shift"]["id"]
respond_to do |format|
if @cyclist.save
format.html { redirect_to "/shifts/#{params['shift']['id']}", notice: "Cyclist data was successfully submitted at #{Time.now.localtime.strftime("%a, %b %d %Y, %I... | [
"def create\n @cyclist = Cyclist.new(params[:cyclist])\n\n respond_to do |format|\n if @cyclist.save\n format.html { redirect_to @cyclist, notice: 'Cyclist was successfully created.' }\n format.json { render json: @cyclist, status: :created, location: @cyclist }\n else\n format.... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
GET /high_schools GET /high_schools.json | def index
@high_schools = HighSchool.all
end | [
"def show\n @highschool = Highschool.find(params[:id])\n \n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @highschool }\n end\n end",
"def index\n @user = User.find(session[:user_id])\n @schools = @user.schools\n respond_to do |format|\n for... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
POST /high_schools POST /high_schools.json | def create
@high_school = HighSchool.new(high_school_params)
respond_to do |format|
if @high_school.save
format.html { redirect_to @high_school, notice: 'High school was successfully created.' }
format.json { render :show, status: :created, location: @high_school }
else
form... | [
"def create\n authorize Highschool\n @highschool = Highschool.new(highschool_params)\n\n respond_to do |format|\n if @highschool.save\n format.html { redirect_to @highschool, notice: 'Srednja šola uspešno dodana.' }\n format.json { render :show, status: :created, location: @highschool }\... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
PATCH/PUT /high_schools/1 PATCH/PUT /high_schools/1.json | def update
respond_to do |format|
if @high_school.update(high_school_params)
format.html { redirect_to @high_school, notice: 'High school was successfully updated.' }
format.json { render :show, status: :ok, location: @high_school }
else
format.html { render :edit }
forma... | [
"def update\n @school = ::Schools::School.find(params[:id])\n\n respond_to do |format|\n if @school.update_attributes(params[:schools])\n format.html { redirect_to @school, notice: 'School was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { ren... | {
"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.