query stringlengths 7 9.5k | document stringlengths 10 1.07M | negatives listlengths 19 19 | metadata dict |
|---|---|---|---|
Set mode, owner and group on a remote path. ==== Attributes +host+ The remote host containing the target path. +path+ The path to set mode, user and group upon. +mode+ The desired mode to set on the path in as a string. +owner+ The owner to set on the path. (Puppet user if not specified.) +group+ The group to set on th... | def set_perms_on_remote(host, path, mode, owner=nil, group=nil)
if (owner.nil?)
owner = on(host, puppet('config', 'print', 'user')).stdout.rstrip
end
if (group.nil?)
group = on(host, puppet('config', 'print', 'group')).stdout.rstrip
end
on(host, "chmod -R #{mode} #{path}")
on(host, "chown -R #{own... | [
"def set_perms_on_remote(host, path, mode, opts = {})\n opts[:owner] ||= on(host, puppet('config print user')).stdout.rstrip\n opts[:group] ||= on(host, puppet('config print group')).stdout.rstrip\n\n on(host, \"chmod -R #{mode} #{path}\")\n on(host, \"chown -R #{opts[:owner]}:#{opts[:group]} #{... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Create a temporary directory environment and inject a "site.pp" for the target environment. ==== Attributes +master+ The master on which to create a new Puppet environment. +env_root_path+ The base path on the master that contains all environments. +env_seed_name+ The seed name to use for generating an environment name... | def create_temp_dir_env(master, env_root_path, env_seed_name, manifest)
env_name = "#{env_seed_name}" + rand(36**16).to_s(36)
env_path = "#{env_root_path}/#{env_name}"
env_site_pp_path = "#{env_path}/manifests/site.pp"
on(master, "mkdir -p #{env_path}/manifests #{env_path}/modules")
set_perms_on_remote(maste... | [
"def mk_tmp_environment(environment)\n # add the tmp_environment to a set to ensure no collisions\n @@tmp_environment_set ||= Set.new\n deadman = 100; loop_num = 0\n while @@tmp_environment_set.include?(tmp_environment = environment.downcase + '_' + random_string) do\n break if ... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
A method for building attribute string | def mk_attr_str **attr_map
attr_map.map{|k,v|" #{k}='#{v}'"}.join
end | [
"def attribute_string\n liner.map { |k,v| \"#{k}=#{v.inspect}\" }.join(', ')\n end",
"def buildAttrString(attributes)\r\n str = \"\"\r\n\r\n attributes.each do |key, val|\r\n str += \" #{key}='#{val}'\"\r\n end # attributes.each\r\n\r\n puts \"attrib str: #{str}\" if $DEBUG\r\n str\r\n... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
A method for building inline tag string | def tag_inline tagname, value, **attr_map
attr_str = mk_attr_str(attr_map)
"<#{tagname}#{attr_str}>#{value}</div>"
end | [
"def gen_simple_tag tag, content, *attribute_strings\n gend_tag = \"<\" + tag\n unless attribute_strings.length == 0\n gend_tag += \" \"\n #use reduce to combine all attributes into a single string \n gend_tag += attribute_strings.reduce do |combined_attr, current_attr|\n combined_attr +... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
A method for indent array | def a_indent arr, level=1
[arr].flatten.map{|e|"#{SP*level}#{e}"}
end | [
"def indent(distance); end",
"def indent!(num = nil, i_char = ' ')\n collect! do |array_element|\n array_element.indent!(num, i_char)\n end\n end",
"def indent(num = nil, i_char = ' ')\n collect do |array_element|\n array_element.indent(num, i_char)\n end\n end",
"def indentx!(num = ni... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
A method for building block level tag string array with class attribute | def tag_block tagname, children, **attr_map
ch = a_indent(children)
attr_str = mk_attr_str(attr_map)
["<#{tagname}#{attr_str}>", ch, "</div>"].flatten
end | [
"def tag_class(*) end",
"def tag_class_list\n tags = self.tags.collect{|tag| tag.slug}\n tags.join(\" \")\n end",
"def build_tags\n @tags.map { |key, value| \"#{key}=#{value}\" }.join(',')\n end",
"def attribute *array\n return self if guard *array\n r = self.clone\n a = ... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
A method for building pair role | def mk_pair_role rpair, plural=false
suffix = plural ? 's' : ''
"#{rpair.join(UBAR)}_pair#{suffix}"
end | [
"def make_roles\n logger.debug \"CALLING CREATE ROLES\"\n self.roles.create :name => \"#{self.cp_title} Edit\", :critical_process_id => self.cp_secondary_id, :edit => true, :review => false\n self.roles.create :name => \"#{self.cp_title} Review\", :critical_process_id => self.cp_secondary_id, :edit => fals... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
A method for building pair from value/role pair with wrapper | def build_pair_div_wrap value_pair, role_pair
pairs = build_pair_div(value_pair, role_pair)
pair_role = mk_pair_role(role_pair)
div_block(pairs, pair_role)
end | [
"def mk_pair_role rpair, plural=false\n suffix = plural ? 's' : ''\n \"#{rpair.join(UBAR)}_pair#{suffix}\"\n end",
"def build_secret_tuple(secrets, required_values, key)\n [key, required_values[key], secrets[key]]\n end",
"def build_pairs_div value_pairs, role_pair\n pairs = value_pairs.map{|p... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
A method for building pairs from value/role pairs | def build_pairs_div value_pairs, role_pair
pairs = value_pairs.map{|pair|build_pair_div_wrap(pair, role_pair)}
pairs_role = mk_pair_role(role_pair, true)
div_block(pairs, pairs_role)
end | [
"def name_and_role\n \n instructors.map do |instructor|\n # role = {}\n # role[ instructor[:name] ] = instructor[:role]\n # role\n Hash[ instructor[:name]=> instructor[:role] ]\n # binding.pry\n end\n \nend",
"def build_pair_div_wrap value_pair, role_pair\n pairs ... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
GET /travel_agent_profiles/1 GET /travel_agent_profiles/1.json | def show
@travel_agent_profile = TravelAgentProfile.find(params[:id])
respond_to do |format|
format.html # show.html.erb
format.json { render json: @travel_agent_profile }
end
end | [
"def get_default_profile \n get(\"/profiles.json/default\")\nend",
"def show\n @agent_profile = AgentProfile.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @agent_profile }\n end\n end",
"def show\n @agentprofile = Agentprofile.find... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
GET /travel_agent_profiles/new GET /travel_agent_profiles/new.json | def new
@travel_agent_profile = TravelAgentProfile.new
respond_to do |format|
format.html # new.html.erb
format.json { render json: @travel_agent_profile }
end
end | [
"def new\n @agentprofile = Agentprofile.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @agentprofile }\n end\n end",
"def new\n @agent_profile = AgentProfile.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { re... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
POST /travel_agent_profiles POST /travel_agent_profiles.json | def create
@travel_agent_profile = TravelAgentProfile.new(params[:travel_agent_profile])
respond_to do |format|
if @travel_agent_profile.save
format.html { redirect_to @travel_agent_profile, notice: 'Travel agent profile was successfully created.' }
format.json { render json: @travel_agen... | [
"def create\n @agent_profile = AgentProfile.new(params[:agent_profile])\n\n respond_to do |format|\n if @agent_profile.save\n format.html { redirect_to root_path, notice: 'Agent profile was successfully created.' }\n format.json { render json: @agent_profile, status: :created, location: @ag... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
PUT /travel_agent_profiles/1 PUT /travel_agent_profiles/1.json | def update
@travel_agent_profile = TravelAgentProfile.find(params[:id])
respond_to do |format|
if @travel_agent_profile.update_attributes(params[:travel_agent_profile])
format.html { redirect_to @travel_agent_profile, notice: 'Travel agent profile was successfully updated.' }
format.json ... | [
"def assign_default_profile(args = {}) \n put(\"/profiles.json/#{args[:profileId]}/default\", args)\nend",
"def update\n @agent_profile = AgentProfile.find(params[:Agent_profile_id])\n\n respond_to do |format|\n if @agent_profile.update_attributes(params[:agent_profile])\n format.html { redirect... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
DELETE /travel_agent_profiles/1 DELETE /travel_agent_profiles/1.json | def destroy
@travel_agent_profile = TravelAgentProfile.find(params[:id])
@travel_agent_profile.destroy
respond_to do |format|
format.html { redirect_to travel_agent_profiles_url }
format.json { head :no_content }
end
end | [
"def destroy\n @agent_profile = AgentProfile.find(params[:id])\n @agent_profile.destroy\n\n respond_to do |format|\n format.html { redirect_to agent_profiles_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @agentprofile = Agentprofile.find(params[:id])\n @agentpr... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Creates CSV report with NET and server benchmarks | def report!
# Fulfill batches array with 1 second step timestamps
#
batches = []
@min_time = Time.at(@min_time.to_f.truncate + 0.999)
batches << @min_time
(@max_time - @min_time).to_i.times {
batches << batches.last + 1.second
}
batches << batches.last + 1.... | [
"def server_report_csv(filename)\n puts 'Creating the VMs report'\n CSV.open(\"#{filename}\", 'w') do |csv|\n csv << %w(VM_List)\n csv << %w(Host_Name LPAR_Name LPAR_State OS_Status LPAR_Health Machine_Name VM_IPaddress VM_Flavor VM_CPU VM_Memory VM_CPU_Utilization VM_CPU_Mode VM_OS VM_CPU_Pool \\\n... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
def reduce_to_total(array, alpha = 0) THE DO WHILE DOESN'T APPEAR TO WORK, WILL EXAMINE LATER total_amount = alpha; counter = 0; loop do total_amount += array[counter]; counter = counter + 1; break if counter < array.length; end return(total_amount); end | def reduce_to_total(array, alpha = 0)
total_amount = alpha;
counter = 0;
while counter < array.length do
total_amount += array[counter];
counter = counter + 1;
end
return(total_amount);
end | [
"def reduce_to_total(array)\n total = 0 \n count = 0 \n while count < array.length do\n total = total + array[count]\n count += 1\n end\n total\nend",
"def total (array)\n x = 0 \n sum = 0\n while x <= array.length-1\n sum += array[x]\n x += 1\n end\n return sum \nend",
"def cust_... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
def reduce_to_all_true(array) THE DO WHILE DOESN'T APPEAR TO WORK, WILL EXAMINE LATER counter = 0; loop do run following block until condition is met... return false if array[counter] == array[counter]; ...return false if any elements is a false value... return false if array[counter] == !array[counter]; ...return fals... | def reduce_to_all_true(array)
counter = 0;
while counter < array.length do
return false if !array[counter];
counter += 1;
end
return(true);
end | [
"def reduce_to_all_true(array)\n i = 0\n while i < array.length do\n if !!(array[i]) == false\n return false\n end\n i += 1\n end\n return true\nend",
"def reduce_to_any_true (array)\r\n val = array.reduce() { |e| array.include?(true) ? e = true : e = false }\r\n p val\r\nend",
"def ... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
%var:image100x100 lang_id is not used! | def build_image_size_variables(src, lang_id, var_hash)
is_admin = var_hash[:admin_view?] == true
src.gsub(/%image[\w]*:[\w\-\"_\']+/) { |r|
resulted_value = ""
image_size_attr = /%image(\w+)/.match(r)
image_size = image_size_attr.nil? ? nil : image_size_attr[1].split("x")
i... | [
"def l10n_getimg(key, view_sym = controller.controller_name, lang = session[:lang] || :en)\n return l10n_translator.getimg(view_sym.to_sym, key, lang)\n end",
"def set_default_alt\n {'zh-TW': name_zh_tw, 'en': name_en}.each do |locale, value|\n img = self.images.where(lang: locale).first\n ... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Returns all circles = (global + user's) | def all_circles
(circles + Circle.globals).uniq
end | [
"def circles(opts = {})\r\n rel_ids = preference.active_circle_ids.sort\r\n rel_ids.reject! {|id| id == Relationshiptype.interested} if opts[:without_interested]\r\n return rel_ids.map(&:to_i) if opts[:just_ids]\r\n\r\n rel_ids.collect{|x| circle(x) }\r\n end",
"def collect_circles(circle: circle, cu... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Adds relationship for guest | def add_guest(guest, circle = guest.circle)
# Adds authorization plugin role: 'guest' of user
# guests can identify their hosts with:
# guest.is_guest_of_what => Array of Members
# and member can identify their guests with:
# member.has_guests? => true/false
# member.has_guests => Arr... | [
"def add_relationship(rel_attr); end",
"def create_relationship(user_invited)\n relationships.create!(friend: user_invited)\n end",
"def add_guest(guest_to_be_added)\n @guests << guest_to_be_added\n end",
"def add_guest_to_room(guest)\n @guests_in_room.push(guest)\n end",
"def attach_relationshi... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Returns of bytes used by backup data | def s3_storage_used
bytes = contents.sum(:size)
backup_sources.gmail.each do |gmail|
bytes += gmail.backup_emails.sum(:size)
end
# TODO: move size calculations to each source
backup_sources.blog.each do |blog|
blog.feed.entries.each do |entry|
if entry.feed_content
bytes += entry.fee... | [
"def disk_bytes_used\n get_device_info[:disk_used]\n end",
"def bytes_needed(count); end",
"def total_bytes\n (wired + active + inactive + free) * pagesize\n end",
"def disk_bytes_total\n get_device_info[:disk_total]\n end",
"def total_bytes\n total_blocks * block_size\n end",
"def... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Test parsing of slides from text into objects | def test_slide_parsing
presentation = Domain::Presentation.new('DE', 'Title1', 'Title2', 3, 'Section 3', '(c) 2014',
'Thomas Smits', 'java', 'Test Presentation', 'WS2014',
false, nil)
parser = Parsing::Parser.new(5, Parsi... | [
"def test_slide_parsing\n\n presentation = Domain::Presentation.new('Title1', 'Title2', 3, 'Section 3', '(c) 2014',\n 'Thomas Smits', 'java', 'Test Presentation', 'WS2014')\n\n parser = Parsing::Parser.new(5, Parsing::ParserHandler.new(true))\n\n\n parser.parse_l... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Attempt to push an item on the queue. If the queue is full, then the behavior is determined by the :drop_oldest setting provided to the constructor. Returns true if the object was pushed on the queue, or false if the queue was full. | def enqueue(object_)
result_ = true
if @push_ptr
if @pop_ptr == @push_ptr
if @drop_oldest
@pop_ptr += 1
@pop_ptr = 0 if @pop_ptr == @buffer.size
result_ = false
else
return false
end
elsif @po... | [
"def pushed?\n !!self.pushed_at\n end",
"def push?\n (self[:th_flags] & PUSH) != 0\n end",
"def process_queue_item #:nodoc:\n return false if @queue.empty?\n\n # Even though we just asked if the queue was empty, it\n # still could have had an item which by this statement\... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Generate standard YAML output, but never include the auto warning message. FIXME: Override to solve a convoluted, `simp config` code problem. Because `simp config` needs to know the scenario to use to build the Item decision tree, it needs to determine this Item's value ahead of time. Then, to make sure this Item is ac... | def to_yaml_s(include_auto_warning = false)
super(false)
end | [
"def auto_warning\n \">> VALUE SET BY `simp config` AUTOMATICALLY. <<\\n\"\n end",
"def create_safety_writer_item\n if file = @options[:safety_save_file]\n FileUtils.mkdir_p File.dirname( file ), :verbose => false\n writer = Simp::Cli::Config::Item::AnswersYAMLFileWriter.new(@options[:puppet... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Responds to request with index_ok status and resources | def index_ok(resources:)
render json: resources, status: :ok, include: index_includes
end | [
"def index\n render_result('ok')\n end",
"def request_res_index(*args)\n @res_index\n end",
"def index\n head params[:response_status]\n end",
"def index_status()\n\n read_index_alias = to_read_index_alias_name()\n write_index_alias = to_write_index_alias_name()\n parsed = @http.g... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
GET /kitchen_items GET /kitchen_items.json | def index
@kitchen_items = KitchenItem.all
end | [
"def show\n @items = Item.find(params[:id])\n render json: @items\n end",
"def index\n @rentable_items = RentableItem.all\n render json: @rentable_items\n end",
"def index\n @inventories = @warehouse.inventories\n\n render json: @inventories\n end",
"def inventory \n @inventories = Inv... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
POST /kitchen_items POST /kitchen_items.json | def create
@kitchen_item = KitchenItem.new(kitchen_item_params)
respond_to do |format|
if @kitchen_item.save
format.html { redirect_to @kitchen_item, notice: 'Kitchen item was successfully created.' }
format.json { render :show, status: :created, location: @kitchen_item }
else
... | [
"def create\n item = list.items.create!(item_params)\n render json: item, status: 201\n end",
"def create\n item = Item.new(item_params)\n item.done = \"0\"\n item.trash = \"0\"\n\n if item.save\n render json: {data:item}, statu... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
PATCH/PUT /kitchen_items/1 PATCH/PUT /kitchen_items/1.json | def update
respond_to do |format|
if @kitchen_item.update(kitchen_item_params)
format.html { redirect_to @kitchen_item, notice: 'Kitchen item was successfully updated.' }
format.json { render :show, status: :ok, location: @kitchen_item }
else
format.html { render :edit }
... | [
"def _update_item(http, headers, path, body, name)\n resp = retry_request(http, \"PATCH\", path, body, headers)\n if resp.is_a?(Net::HTTPOK)\n Chef::Log.info(\"Updated keystone item '#{name}'\")\n else\n _raise_error(resp, \"Unable to update item '#{name}'\", \"_update_item\")\n end\nend",
"def update\n... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
POST /imagedemos POST /imagedemos.json | def create
@imagedemo = Imagedemo.new(imagedemo_params)
respond_to do |format|
if @imagedemo.save
format.html { redirect_to @imagedemo, notice: 'Imagedemo was successfully created.' }
format.json { render action: 'show', status: :created, location: @imagedemo }
else
format.h... | [
"def upload_image_file(args = {}) \n post(\"/files.json/captiveportal/images\", args)\nend",
"def upload_floor_plan(args = {}) \n post(\"/files.json/floorplan/images\", args)\nend",
"def add_image\n if request.post? == false\n render :json => { :message => \"Error\" }\n return\n end\n\n # Ad... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
DELETE /imagedemos/1 DELETE /imagedemos/1.json | def destroy
@imagedemo.destroy
respond_to do |format|
format.html { redirect_to imagedemos_url }
format.json { head :no_content }
end
end | [
"def delete_floor_plan(args = {}) \n delete(\"/files.json/floorplan/images\", args)\nend",
"def destroy\n @image.destroy\n\n respond_to do |format|\n format.json { head :no_content }\n end\n end",
"def destroy\n @image = Image.find(params[:id])\n @image.destroy\n render json: {status: \"... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Calculate password hash from string for use in 'password' fields. | def password_hash(pwd)
hsh = 0
pwd.reverse.each_char { |c|
hsh = hsh ^ c.ord
hsh = hsh << 1
hsh -= 0x7fff if hsh > 0x7fff
}
(hsh ^ pwd.length ^ 0xCE4B).to_s(16)
end | [
"def hash_password(password)\n self.password_algorithm = self.class.password_algorithm\n self.password_salt = SaltedHash::salt\n self.password_hash = SaltedHash::compute(password_algorithm, password, password_salt)\n end",
"def digest(string)\n User.digest(string, self.password_salt)\n end",
"def ... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
by default, only sets cell to nil if :left is specified, method will shift row contents to the right of the deleted cell to the left if :up is specified, method will shift column contents below the deleted cell upward | def delete_cell(row_index = 0, column_index=0, shift=nil)
validate_workbook
validate_nonnegative(row_index)
validate_nonnegative(column_index)
row = sheet_data[row_index]
old_cell = row && row[column_index]
case shift
when nil then
row.cells[column_index] = nil if row... | [
"def delete_cell(row=0,col=0,shift=nil)\n validate_workbook\n validate_nonnegative(row)\n validate_nonnegative(col)\n if @sheet_data.size <= row || @sheet_data[row].size <= col\n return nil\n end\n\n cell = @sheet_data[row][col]\n @sheet_data[row][col]=nil\n\n if shift && shift != :left... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Get raw column width value as stored in the file | def get_column_width_raw(column_index = 0)
validate_workbook
validate_nonnegative(column_index)
range = cols.locate_range(column_index)
range && range.width
end | [
"def width\n flat_file_data[:width]\n end",
"def column_width\n return @column_width\n end",
"def returnWidth\n ## 4 byte signed integer\n isWidth ? @RecordData[0] : UNKNOWN\n end",
"def column_width\n (@column_width || Blueprint::COLUMN_WIDTH).to_i\n end",
"... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Helper method to get the style index for a column | def get_col_style(column_index)
range = cols.locate_range(column_index)
(range && range.style_index) || 0
end | [
"def get_col_style(column_index)\n range = cols.find(column_index)\n (range && range.style_index) || 0\n end",
"def get_col_style(column_index)\n range = cols.locate_range(column_index)\n (range && range.style_index) || 0\n end",
"def col_style(index, style, options = T.unsafe(nil)); end",
"def ... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Helper method to update the row styles array change_type NAME or SIZE or COLOR etc main method to change font, called from each separate font mutator method | def change_row_font(row_index, change_type, arg, font)
validate_workbook
ensure_cell_exists(row_index)
xf = workbook.register_new_font(font, get_row_xf(row_index))
row = sheet_data[row_index]
row.style_index = workbook.register_new_xf(xf)
row.cells.each { |c| c.font_switch(change_ty... | [
"def change_row_font(row, change_type, arg, font, xf_id)\n validate_workbook\n validate_nonnegative(row)\n increase_rows(row)\n\n # Modify font array and retrieve new font id\n font_id = modify_font(@workbook, font, xf_id[:fontId].to_s)\n # Get copy of xf object with modified font id\n xf = dee... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Changes font name of cell | def change_font_name(new_font_name = 'Verdana')
validate_worksheet
font = get_cell_font.dup
font.set_name(new_font_name)
update_font_references(font)
end | [
"def change_column_font_name(col=0, font_name='Verdana')\n # Get style object\n xf_id = xf_id(get_col_style(col))\n # Get copy of font object with modified name\n font = deep_copy(@workbook.fonts[xf_id[:fontId].to_s][:font])\n font[:name][:attributes][:val] = font_name.to_s\n # Update font and xf ... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Changes font size of cell | def change_font_size(font_size = 10)
validate_worksheet
raise 'Argument must be a number' unless font_size.is_a?(Integer) || font_size.is_a?(Float)
font = get_cell_font.dup
font.set_size(font_size)
update_font_references(font)
end | [
"def change_font_size(font_size=10)\n validate_worksheet\n raise 'Argument must be a number' unless font_size.is_a?(Integer) || font_size.is_a?(Float)\n\n font = get_cell_font.dup\n font.set_size(font_size)\n update_font_references(font)\n end",
"def change_column_font_size(col=0, font... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Changes font color of cell | def change_font_color(font_color = '000000')
validate_worksheet
Color.validate_color(font_color)
font = get_cell_font.dup
font.set_rgb_color(font_color)
update_font_references(font)
end | [
"def text_color=(color)\n @subtable.cells.text_color = color\n end",
"def change_column_font_color(col=0, font_color='000000')\n Color.validate_color(font_color)\n # Get style object\n xf_id = xf_id(get_col_style(col))\n # Get copy of font object with modified color\n font = deep_co... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Changes font italics settings of cell | def change_font_italics(italicized = false)
validate_worksheet
font = get_cell_font.dup
font.set_italic(italicized)
update_font_references(font)
end | [
"def change_font_italics(italicized=false)\n validate_worksheet\n\n font = get_cell_font.dup\n font.set_italic(italicized)\n update_font_references(font)\n end",
"def change_row_italics(row=0, italicized=false)\n # Get style object\n xf_id = xf_id(get_row_style(row))\n # Get copy o... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Changes font bold settings of cell | def change_font_bold(bolded = false)
validate_worksheet
font = get_cell_font.dup
font.set_bold(bolded)
update_font_references(font)
end | [
"def change_font_bold(bolded=false)\n validate_worksheet\n\n font = get_cell_font.dup\n font.set_bold(bolded)\n update_font_references(font)\n end",
"def bold_cell(options = {}, &block)\n cell({ font_style: :bold }.merge(options || {}), &block)\n end",
"def enter_bold_mode\n ... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Changes font underline settings of cell | def change_font_underline(underlined = false)
validate_worksheet
font = get_cell_font.dup
font.set_underline(underlined)
update_font_references(font)
end | [
"def change_font_underline(underlined=false)\n validate_worksheet\n\n font = get_cell_font.dup\n font.set_underline(underlined)\n update_font_references(font)\n end",
"def change_row_underline(row=0, underlined=false)\n # Get style object\n xf_id = xf_id(get_row_style(row))\n # Get... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Sign out users that expired, but check each 5min or so | def sign_out_expired_session
return unless current_user.present?
return if current_user.last_sign_in_check.present? && current_user.last_sign_in_check <= 5.minutes.ago
current_user.update last_sign_in_check: Time.now
if UniversumSsoClient.signed_out?(current_user.uid)
session[:user_id] = nil
... | [
"def clean_expired!\n sessions.remove( { :expire => { '$lt' => Time.now } } )\n end",
"def perform\n inactive_users = User.inactive_for_more_than(2.days)\n inactive_users.destroy_all\n end",
"def logout_if_timedout\n # Make sessions timeout after 30 minutes without a request\n ... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
instantiate car, beginning with an empty cars array, then running ready_go method | def initialize
@cars = []
ready_go
end | [
"def ready_go\n @cars << Car.new\n @cars << Car.new\n\n @cars.first.accelerate(random_speed)\n @cars.last.accelerate(random_speed)\n end",
"def initialize\n\t\t@cars = []\n\tend",
"def initialize\n\t\t@cars = Array.new(2) { |i| Car.new }\n\t\t@cars.each { |car| car.accelerate(rand(1..100)) }\n\tend... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
method runs when race is instantiated; creates 2 new car instances runs accelerate method from Car class on both new cars and sets random speed | def ready_go
@cars << Car.new
@cars << Car.new
@cars.first.accelerate(random_speed)
@cars.last.accelerate(random_speed)
end | [
"def race \n\t\t@cars << Car.new\n\t\t@cars.first.accelerate\n\tend",
"def initialize\n\t\t@cars = Array.new(2) { |i| Car.new }\n\t\t@cars.each { |car| car.accelerate(rand(1..100)) }\n\tend",
"def car_accelerate()\n @speed += 10\n @fuel_level -= 5\nend",
"def accelerate(new_speed)\n @speed = new_speed\n ... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
gets winner by sorting the two cars by speed; car with higher speed will be last and is the winner | def winner
@cars.sort_by(&:speed).last
end | [
"def winner\n\t\t@cars.sort_by(&:speed)\n\tend",
"def loser\n @cars.sort_by(&:speed).first\n end",
"def determine_winner\n @active_players.sort! do |player1, player2|\n if player1.strongest_hand > player2.strongest_hand\n -1\n elsif player1.strongest_hand < player2.strongest_hand\n 1\n e... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
gets loser by sorting the two cars by speed; car with lower speed will be first and is the loser | def loser
@cars.sort_by(&:speed).first
end | [
"def winner\n\t\t@cars.sort_by(&:speed)\n\tend",
"def winner\n @cars.sort_by(&:speed).last\n end",
"def sort_drivers\n @drivers.sort! {|x, y| y.miles_driven <=> x.miles_driven}\n end",
"def cars_sorted_by_price\n sort = []\n @inventory.each do |car|\n sort << car.loan_length * car.monthly_... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Returns an adjacent enemy with the lowest HP and in reading order. | def find_adjacent_enemy(unit)
neighbors(unit.pos)
.map { |p| @units.find { |u| u.pos == p } }
.select { |u| u&.alive? && u.type != unit.type }
.min_by { |u| [u.hp, u.pos] }
end | [
"def nearest_enemy()\n targets = @enemies.select {|enemy| enemy.position(now)}\n targets.sort! {|a,b| a.position(now).distance(self.position(now)) <=> b.position(now).distance(self.position(now))}\n #puts \"Enemy: #{targets.first.name} is in range\" if VERBOSE and !targets.empty? and targets.fi... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Returns the shortest path from src to one of the destinations. If there are multiple shortest paths, e.g. A>B has the same length as A>C, returns all of them. | def shortest_paths(src, destinations)
return [] if destinations.empty?
paths = []
visited = Set.new([src])
queue = Containers::MinHeap.new
queue.push([1, [src]])
until queue.empty?
_, path = queue.pop
# Not going to find shorter paths than current best, return.
break if path... | [
"def find_shortest_path(source, dest, graph = @graph)\n queue = [[source]]\n visited = Set.new\n\n until queue.empty?\n path = queue.shift\n vertex = path.last\n return path if vertex == dest\n\n next if visited.include?(vertex)\n\n graph[vertex].each do |curr_node|\n new_pa... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
The introspection system is prepared with a bunch of LateBoundTypes. Replace those with the objects that they refer to, since LateBoundTypes aren't handled at runtime. | def resolve_late_bindings
@types.each do |name, t|
if t.kind.fields?
t.fields.each do |_name, field_defn|
field_defn.type = resolve_late_binding(field_defn.type)
end
end
end
@entry_point_fields.each do |name, f|
f.type = resolv... | [
"def replace_late_bound_types_with_built_in(types); end",
"def replace_late_bound_types_with_built_in(types)\n GraphQL::Schema::BUILT_IN_TYPES.each do |scalar_name, built_in_scalar|\n existing_type = types[scalar_name]\n if existing_type.is_a?(GraphQL::Schema::LateBoundType)\n ... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Challenge 2 Calculator Create a simple calculator that first asks the user what method they would like to use (addition, subtraction, multiplication, division) and then asks the user for two numbers, returning the result of the method with the two numbers. Here is a sample prompt: What calculation would you like to do?... | def calculator
#ask user method
puts "What calculation would you like to do? (add, sub, mult, div)"
calc_type = gets.chomp
#ask for first number
puts "What is number 1? where result = num_1 operator num_2"
num_1 = gets.chomp
num_1 = num_1.to_f
#ask for second number
puts "What is n... | [
"def calculator()\n\tprint \"What method would you like to use? Add? Sub? Times? Divide? \"\n\toper = gets.chomp.downcase\n\tif oper == \"add\" || oper == \"sub\" || oper == \"times\" || oper == \"divide\"\n\t\tprint \"What is your first number? \"\n\t\tnumOne = gets.chomp.to_i\n\t\tprint \"What is your second numb... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Override this method so that Rails uses :ssn in routes instead of :id | def to_param
ssn
end | [
"def ssn=(ssn)\n @ssn = ssn\n self.encrypted_ssn = Encryptor.one_way_encrypt_string(ssn)\n end",
"def singular_route_key; end",
"def sanitize_ssn\n begin\n ssn = \"%09d\" % self.to_numeric.to_i\n raise \"Too Long\" if ssn.length > 9\n area, group, serial = ssn[0..2], ssn[3..4], ssn[5..8... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Generate url that will redirect user to OAuth Dialogue. The canvas url should start by https:// and end with a slash. If you're building an facebook app, the canvas_url should be something like | def dialogue_url
return "https://www.facebook.com/dialog/oauth?client_id="+@app_id+"&redirect_uri="+@canvas_url+"&scope="+@permission
end | [
"def oauth_redirect_uri\n uri = URI.parse(request.url)\n uri.path = '/sk_auth/callback'\n uri.query = nil\n uri.to_s\n end",
"def oauth_callback_url\n complete_oauth_login_url\n end",
"def canvas_page_url(protocol)\n \"#{ protocol }apps.facebook.com/#{ namespace }\"\n ... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
GET /donation_record/actual_funds GET /donation_record/actual_funds.json | def index
@donation_record_actual_funds = DonationRecord::ActualFund.all
end | [
"def show\n @fund_donation = FundDonation.find(params[:id])\n\n render json: @fund_donation\n end",
"def getWithdrawalFees\n request \"/Payment/getWithdrawalFees.json\"\n end",
"def index\n @funds = Fund.all\n\n render json: @funds\n end",
"def show\n @fund_record = FundRe... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
POST /donation_record/actual_funds POST /donation_record/actual_funds.json | def create
# raise donation_record_actual_fund_params.inspect
@donation_record_actual_fund = DonationRecord::ActualFund.new(donation_record_actual_fund_params)
@donation_record_actual_fund.donation_record = @donation_record
respond_to do |format|
if @donation_record_actual_fund.save
format... | [
"def create\n @fund = Fund.new(fund_params)\n\n if @fund.save\n render json: @fund, status: :created, location: @fund\n else\n render json: @fund.errors, status: :unprocessable_entity\n end\n end",
"def create\n @fund_donation = FundDonation.new(fund_donation_params)\n\n if @f... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
PATCH/PUT /donation_record/actual_funds/1 PATCH/PUT /donation_record/actual_funds/1.json | def update
respond_to do |format|
if @donation_record_actual_fund.update(donation_record_actual_fund_params)
format.html { redirect_to @donation_record }
format.json { render :show, status: :ok, location: @donation_record_actual_fund }
else
format.html { render :edit }
fo... | [
"def update\n if @fund.update(fund_params)\n head :no_content\n else\n render json: @fund.errors, status: :unprocessable_entity\n end\n end",
"def update\n @fund = Fund.find(params[:id])\n\n respond_to do |format|\n if @fund.update_attributes(params[:fund])\n format.html { re... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
DELETE /donation_record/actual_funds/1 DELETE /donation_record/actual_funds/1.json | def destroy
@donation_record_actual_fund.destroy
respond_to do |format|
format.html { redirect_to @donation_record}
format.json { head :no_content }
end
end | [
"def destroy\n @fund_record = FundRecord.find(params[:id])\n @fund_record.destroy\n\n respond_to do |format|\n format.html { redirect_to fund_records_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @financial_donation = FinancialDonation.find(params[:id])\n @fina... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Public: insert Allows a person to insert an object into the "dogs" table. Parameters: No Parameters Returns: id State changes: NA? This method IS working. | def insert
DATABASE.execute("INSERT INTO dogs (name, breed, age, serial_num, colour, description, temperament_id, owner_id) VALUES
('#{@name}', '#{@breed}', #{@age}, #{@serial_num}, '#{@colour}', '#{@description}', #{@temperament_id}, #{@owner_id})")
@id = DATABASE.last_insert_row_id
end | [
"def insert_into_dog(id, shopId, name, imageUrl, happiness, adopted)\n dog = \"INSERT INTO dogs_info (id, shopId, name, imageUrl, happiness, adopted) VALUES AT ($1, $2, $3, $4, $5, $6)\"\n\n result = @db.exec_params(dog, [id, shopId, name, imageUrl, happiness, adopted])\n result.entries\n en... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
return all contracts for a clan newest first | def get_contracts
Contract.where(clan_id: id).order('start_date_time desc')
end | [
"def fetch_contracts\n contracts = []\n self.fetch[\"result\"].first.first[1].each do |contract|\n contracts << USA::Contract.new(contract)\n end\n return contracts\n end",
"def newest\n current_bank.pop\n end",
"def latest\n return self.transactions.first(:order =... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
GET /dianosaurs GET /dianosaurs.json | def index
@dianosaurs = Dianosaur.all
end | [
"def index\n @dinos = Dino.where(query_params)\n render json: @dinos\n end",
"def index\n @dioceses = Diocese.all\n\n render json: @dioceses\n end",
"def index\n @api_stadia = Api::Stadium.all\n render json: @api_stadia\n end",
"def show\n dinosaurs = Dinosaur.filter_by_species(params[... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
POST /dianosaurs POST /dianosaurs.json | def create
@dianosaur = Dianosaur.new(dianosaur_params)
respond_to do |format|
if @dianosaur.save
format.html { redirect_to @dianosaur, notice: 'Dianosaur was successfully created.' }
format.json { render :show, status: :created, location: @dianosaur }
else
format.html { ren... | [
"def create\n @soupdejour = Soupdejour.new(params[:soupdejour])\n\n respond_to do |format|\n if @soupdejour.save\n format.html { redirect_to @soupdejour, notice: 'Soupdejour was successfully created.' }\n format.json { render json: @soupdejour, status: :created, location: @soupdejour }\n ... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
GET /profile_diet_tags GET /profile_diet_tags.json | def index
@profile_diet_tags = ProfileDietTag.all
end | [
"def get_tags_by_url\n url = Url.find_by(id: params[:id])\n tags = url.tags\n render json: {code: 200, tags: tags}\n end",
"def all_tags\n request(:get,\"/tags\")\n end",
"def show\n params[:page] ||= 1\n @tag = Tag.find_by_name(params[:id]) || raise_404\n @taggings = @t... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
POST /profile_diet_tags POST /profile_diet_tags.json | def create
@profile_diet_tag = ProfileDietTag.new(profile_diet_tag_params)
respond_to do |format|
if @profile_diet_tag.save
format.html { redirect_to @profile_diet_tag, notice: 'Profile diet tag was successfully created.' }
format.json { render :show, status: :created, location: @profile_... | [
"def create\n tags = @profile.relations_from(current_profile)\n tags << params[:tags].split(',')\n tags.flatten!\n tags.uniq!\n current_profile.tag(@profile, :with => tags.join(','), :on => :relations)\n\n current_profile.filters.tagged_with(tags).each do |filter|\n filter.profiles << @profil... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
PATCH/PUT /profile_diet_tags/1 PATCH/PUT /profile_diet_tags/1.json | def update
respond_to do |format|
if @profile_diet_tag.update(profile_diet_tag_params)
format.html { redirect_to @profile_diet_tag, notice: 'Profile diet tag was successfully updated.' }
format.json { render :show, status: :ok, location: @profile_diet_tag }
else
format.html { ren... | [
"def update\n @tag.update(tag_params)\n render json: @tag\n end",
"def update\n respond_to do |format|\n if @pet_tag.update(pet_tag_params)\n format.html { redirect_to @pet_tag, notice: 'Pet tag was successfully updated.' }\n format.json { render :show, status: :ok, location: @pet_tag... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
DELETE /profile_diet_tags/1 DELETE /profile_diet_tags/1.json | def destroy
@profile_diet_tag.destroy
respond_to do |format|
format.html { redirect_to profile_diet_tags_url, notice: 'Profile diet tag was successfully destroyed.' }
format.json { head :no_content }
end
end | [
"def destroy\n tag = params[:id] # 'tag'\n old_tags = @profile.relations_from(current_profile) # ['tag1', 'tag2', ...]\n new_tags = old_tags - [tag] # ['tag1', 'tag2', ...] - ['tag']\n current_profile.tag(@profile, :with => new_tags.join(','), :on => :relations) # 'tag1,tag2'\n\n current_profile.filt... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
TODO: separate apply_changes! and import! | def import!
return unless imported? or updated?
Outgoing::Workcamp.transaction do
import_changes.each do |change|
change.apply(self)
change.destroy
end
self.state = nil
save!
end
end | [
"def transform_and_import\n transform_files\n import\n end",
"def post_import\n end",
"def import\n\n end",
"def before_import\n end",
"def after_import_synchronize( instances )\n instances.each { |e| e.reload }\n end",
"def import!\n import_binary_files\n member_ids = []\n... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
puts " "4 + ""1 + " "2 + ""1 puts " "3 + ""2 + " "2 + ""2 puts " "2 + ""3 + " "2 + ""3 puts " "1 + ""4 + " "2 + ""4 puts " "0 + ""5 + " "2 + ""5 end pyramid | def pyramid(height)
level = 1
height.times do
puts " "*(height-level) + "#"*level + " "*2 + "#"*level
level += 1
end
end | [
"def wtf_pyramid\n puts \"Entre un nombre?\"\n n = gets.chomp.to_i\n full_pyramid(n / 2 + 1)\n\n (n/2).times do |i|\n i = i+1\n print \" \" * (i)\n puts \"#\" * (n-2*i)\n end\nend",
"def wtf_pyramid\n\tputs \"*\" * 50\n\tputs\"Salut, Bienvenue dans ma super pyramide\"\n\tputs \"Nous allons construir... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Send text messages to all participants with their assignment. | def notify_participants participants
participants.each do |participant|
send_message participant.to_participant_message, participant.phone_number
puts "#{participant.name} has received a text message at #{participant.phone_number}"
end
end | [
"def broadcast_message(text)\n @users.each {|u| u.enqueue_message(text) }\n end",
"def send_all_quiz_participants(quiz_id, message)\n @clients.each do |websocket, client|\n if (@quiz_participants[quiz_id].include?(client) || @tv_clients.include?(websocket))\n websocket.send message\n end\n... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
sends a backup message to a specified phone number with all assignments. | def send_backup_message participants, phone_number
intro = "here are the secret santa assignments:\n"
message = intro + participants.map(&:to_backup_message).join("\n")
send_message message, phone_number
puts "a backup of all assignments has been sent to #{phone_number}"
end | [
"def backup_wallet\n client.make_request('/backup-wallet', 'post', params: {})\n end",
"def backupwallet(destination)\n coind.backupwallet destination\n end",
"def backup=(value)\n @backup = value\n end",
"def cmd_backup argv\n setup argv\n command = @hash['command']\n name = @... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
(re) init with given args and frame types | def init(arguments_type, frame_type)
raise "Wrong argument type, expect Type not #{arguments_type.class}" unless arguments_type.is_a? Type
raise "Wrong frame type, expect Type not #{frame_type.class}" unless frame_type.is_a? Type
@arguments_type = arguments_type
@frame_type = frame_type
@b... | [
"def build(args={})\n klass = FRAME_TYPE_MAP[args[:type].to_i]\n if(klass == FrameType::Response)\n klass.new(:response => args[:data])\n elsif(klass == FrameType::Error)\n klass.new(:error => args[:data])\n elsif(klass == FrameType::Message)\n unpacked = args[... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
determine if method has a local variable or tmp (anonymous local) by given name | def has_local( name )
raise "has_local #{name}.#{name.class}" unless name.is_a? Symbol
@frame_type.variable_index( name )
end | [
"def has_local name\n raise \"has_local #{name}.#{name.class}\" unless name.is_a? Symbol\n index = self.locals.index_of(name)\n index = self.tmps.index_of(name) unless index\n index\n end",
"def has_var name\n name = name.to_sym\n var = @args.find {|a| a.name == name }\n var ... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
GET /child_development_periods GET /child_development_periods.json | def index
@child_development_periods = ChildDevelopmentPeriod.all
end | [
"def index\n @child_developments = ChildDevelopment.all\n end",
"def create\n @child_development_period = ChildDevelopmentPeriod.new(child_development_period_params)\n\n respond_to do |format|\n if @child_development_period.save\n format.html { redirect_to @child_development_period, notice: ... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
POST /child_development_periods POST /child_development_periods.json | def create
@child_development_period = ChildDevelopmentPeriod.new(child_development_period_params)
respond_to do |format|
if @child_development_period.save
format.html { redirect_to @child_development_period, notice: 'Child development period was successfully created.' }
format.json { ren... | [
"def index\n @child_development_periods = ChildDevelopmentPeriod.all\n end",
"def update\n respond_to do |format|\n if @child_development_period.update(child_development_period_params)\n format.html { redirect_to @child_development_period, notice: 'Child development period was successfully upda... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
PATCH/PUT /child_development_periods/1 PATCH/PUT /child_development_periods/1.json | def update
respond_to do |format|
if @child_development_period.update(child_development_period_params)
format.html { redirect_to @child_development_period, notice: 'Child development period was successfully updated.' }
format.json { render :show, status: :ok, location: @child_development_perio... | [
"def update\n respond_to do |format|\n if @child_development.update(child_development_params)\n format.html { redirect_to @child_development, notice: 'Child development was successfully updated.' }\n format.json { render :show, status: :ok, location: @child_development }\n else\n f... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
DELETE /child_development_periods/1 DELETE /child_development_periods/1.json | def destroy
@child_development_period.destroy
respond_to do |format|
format.html { redirect_to child_development_periods_url, notice: 'Child development period was successfully destroyed.' }
format.json { head :no_content }
end
end | [
"def destroy\n @child_development.destroy\n respond_to do |format|\n format.html { redirect_to child_developments_url, notice: 'Child development was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n @time_period.destroy\n format.json { head :no_c... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Update an existing LDAP identity source Update the configuration of an existing LDAP identity source. You may wish to verify the new configuration using the POST /aaa/ldapidentitysources?action&x3D;probe API before changing the configuration. | def create_or_update_ldap_identity_source_with_http_info(ldap_identity_source_id, ldap_identity_source, opts = {})
if @api_client.config.debugging
@api_client.config.logger.debug 'Calling API: SystemAdministrationSettingsUserManagementLDAPIdentitySourcesApi.create_or_update_ldap_identity_source ...'
... | [
"def update\n @admin_source = Admin::Source.find(params[:id])\n\n respond_to do |format|\n if @admin_source.update_attributes(params[:admin_source])\n format.html { redirect_to admin_sources_url, notice: 'Source was successfully updated.' }\n format.json { head :no_content }\n else\n ... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Delete an LDAP identity source Delete an LDAP identity source. Users defined in that source will no longer be able to access NSX. | def delete_ldap_identity_source(ldap_identity_source_id, opts = {})
delete_ldap_identity_source_with_http_info(ldap_identity_source_id, opts)
nil
end | [
"def delete()\n raise InvalidDataError, 'Cannot delete a Managed source query that hasn\\'t been prepared' unless @managed_source_id\n\n begin\n @user.callAPI('source/delete', { 'id' => @managed_source_id })\n rescue APIError => err\n case err.http_code\n when 400\n # Mi... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Delete an LDAP identity source Delete an LDAP identity source. Users defined in that source will no longer be able to access NSX. | def delete_ldap_identity_source_with_http_info(ldap_identity_source_id, opts = {})
if @api_client.config.debugging
@api_client.config.logger.debug 'Calling API: SystemAdministrationSettingsUserManagementLDAPIdentitySourcesApi.delete_ldap_identity_source ...'
end
# verify the required parameter... | [
"def delete_ldap_identity_source(ldap_identity_source_id, opts = {})\n delete_ldap_identity_source_with_http_info(ldap_identity_source_id, opts)\n nil\n end",
"def delete()\n raise InvalidDataError, 'Cannot delete a Managed source query that hasn\\'t been prepared' unless @managed_source_id\n\n ... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
List LDAP identity sources Return a list of all configured LDAP identity sources. | def list_ldap_identity_sources(opts = {})
data, _status_code, _headers = list_ldap_identity_sources_with_http_info(opts)
data
end | [
"def list_sources\n log_message( \"Listing sources...\" ) unless @logging == false\n source_list = @connection.get( \"source\" )\n return source_list\n end",
"def list_data_sources\n response = connection.get(\"/v1/import/data_sources\")\n preprocess_response(response)[:data_sources]\n ... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
List LDAP identity sources Return a list of all configured LDAP identity sources. | def list_ldap_identity_sources_with_http_info(opts = {})
if @api_client.config.debugging
@api_client.config.logger.debug 'Calling API: SystemAdministrationSettingsUserManagementLDAPIdentitySourcesApi.list_ldap_identity_sources ...'
end
if @api_client.config.client_side_validation && !opts[:'pa... | [
"def list_ldap_identity_sources(opts = {})\n data, _status_code, _headers = list_ldap_identity_sources_with_http_info(opts)\n data\n end",
"def list_sources\n log_message( \"Listing sources...\" ) unless @logging == false\n source_list = @connection.get( \"source\" )\n return source_list\n ... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Probe an LDAP identity source Verify that the configuration of an LDAP identity source is correct before actually creating the source. | def probe_unconfigured_ldap_identity_source_probe_identity_source_with_http_info(ldap_identity_source, opts = {})
if @api_client.config.debugging
@api_client.config.logger.debug 'Calling API: SystemAdministrationSettingsUserManagementLDAPIdentitySourcesApi.probe_unconfigured_ldap_identity_source_probe_ide... | [
"def read_ldap_identity_source_with_http_info(ldap_identity_source_id, opts = {})\n if @api_client.config.debugging\n @api_client.config.logger.debug 'Calling API: SystemAdministrationSettingsUserManagementLDAPIdentitySourcesApi.read_ldap_identity_source ...'\n end\n # verify the required para... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Read a single LDAP identity source Return details about one LDAP identity source | def read_ldap_identity_source(ldap_identity_source_id, opts = {})
data, _status_code, _headers = read_ldap_identity_source_with_http_info(ldap_identity_source_id, opts)
data
end | [
"def read_ldap_identity_source_with_http_info(ldap_identity_source_id, opts = {})\n if @api_client.config.debugging\n @api_client.config.logger.debug 'Calling API: SystemAdministrationSettingsUserManagementLDAPIdentitySourcesApi.read_ldap_identity_source ...'\n end\n # verify the required para... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Read a single LDAP identity source Return details about one LDAP identity source | def read_ldap_identity_source_with_http_info(ldap_identity_source_id, opts = {})
if @api_client.config.debugging
@api_client.config.logger.debug 'Calling API: SystemAdministrationSettingsUserManagementLDAPIdentitySourcesApi.read_ldap_identity_source ...'
end
# verify the required parameter 'ld... | [
"def read_ldap_identity_source(ldap_identity_source_id, opts = {})\n data, _status_code, _headers = read_ldap_identity_source_with_http_info(ldap_identity_source_id, opts)\n data\n end",
"def show\n @ldap_auth_header = Irm::LdapAuthHeader.list_all.find(params[:id])\n puts @ldap_auth_header.ldap... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Gets recommended topics for the user based on the topics he have visited | def recommended_topics(limit = 10)
visited_topics.joins(:topic).where('topics.language = ?', I18n.locale).group('topic_id').order("visits DESC, updated_at DESC").limit(limit).map(&:topic).map { |t| t.find_related_tags.limit(2) }.flatten.uniq[0...limit]
end | [
"def get_suggested_topics(assignment_id)\n team_id = TeamsUser.team_id(assignment_id, session[:user].id)\n teams_users = TeamsUser.where(team_id: team_id)\n teams_users_array = Array.new\n teams_users.each do |teams_user|\n teams_users_array << teams_user.user_id\n end\n @suggested_topics = S... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Get if is a new user or not | def new_user?
self.created_at > 1.month.ago
end | [
"def user_create?\n is_user_create\n end",
"def new_user?\n hashed_password.blank?\n end",
"def new?(user)\n not read? and user != sender\n end",
"def auto_create_user?(attrs)\n false\n end",
"def register_new_user\n 'successful_register' == @xml['status'].to_s ? true : false\n e... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Get if the user already thanked the topic specified | def already_thanked?(topic)
notification = Notification.thanked_by(self.id, topic.id)
!notification.empty?
end | [
"def thanked_by?(user)\n result = self.notifications.where(:sender_id => user.id)\n !result.empty?\n end",
"def has_glanced_topic?(topic)\n has_read_topic?(topic).to_i < 0\n end",
"def needs_thanks?\n granted? && !thanked?\n end",
"def already_replied? client, user\n client.user_timeline(\"cru... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Get if the user already welcomed the user specified | def already_welcomed?(user)
notification = Notification.welcomed_by(self.id, user.id)
!notification.empty?
end | [
"def user_has_been_muted?\n \tif UserMute.where(user_id: @user.id, chat_room_id: @chat_room.id).exists?\n \t\tflash[:danger] = \"User already has been muted.\"\n \t\tredirect_to chat_room_path(@chat_room)\n \tend\n end",
"def thanked_by?(user)\n result = self.notifications.where(:sender_id => user.id)\n ... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Adds a subscription for the user to the given topic | def subscribe_to(topic)
StreamUser.create(:user => self, :stream_message => topic.stream_messages.last, :source => 'followed') if topic.stream_messages.last
subscriptions << Subscription.new(:topic => topic)
end | [
"def subscribe_to_topic(tokens, topic)\n make_topic_mgmt_request(tokens, topic, \"batchAdd\")\n end",
"def subscribe(_topic, **)\n raise 'not implemented'\n end",
"def upsert_subscription(topic, name, opts = {})\n sub_config = opts.to_h.merge(endpoint: webhook_url)\n\n ... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Removes subscriptions for this user to the given topic | def unsubscribe_from(topic)
subscriptions.find_by_topic_id(topic.id).try(:destroy)
end | [
"def unsubscribe_from_topic(tokens, topic)\n make_topic_mgmt_request(tokens, topic, \"batchRemove\")\n end",
"def unsubscribe(*topics)\n # FIXME: make sure @connection isn't nil\n @connection.unsubscribe(*topics)\n end",
"def unsubscribe(topic)\n Util.error_check \"unsubscribing from... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Finds subscription to the given topic | def subscription_for(topic)
subscriptions.where(:topic_id => topic.id).first
end | [
"def find_topic(topic)\n @subscription_group.topics.find(topic) || raise(Errors::TopicNotFoundError, topic)\n end",
"def find_topic\n @topic = current_user.topics.find(params[:topic_id])\n end",
"def find_subscription(key)\n subscriptions.where(key: key).first\n end",
"def subscribe_to... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
if a user is destroyed change the ownership of its topics to admin | def change_topics_owner
self.topics.each do |topic|
topic.user = User.where(:is_admin => true).first
topic.save!
end
end | [
"def remove_user(user)\n self.user_ids.delete user.id\n self.save\n user.topic_ids.delete self.id\n user.save\n end",
"def destroy\n @topics_user = TopicsUser.find(params[:id])\n @topics_user.destroy\n\n respond_to do |format|\n format.html { redirect_to my_topics_url,... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
send notification to participate in a topic | def notify_about_topic!(topic)
with_user_locale do
UserMailer.topic_match_notification(self, topic).deliver!
end
end | [
"def send_message_to_est(topic)\n user = User.where('edutorid like ?','%EST-%').first\n message = Message.new\n message.sender_id = current_user.id\n message.recipient_id = user.id\n message.subject = \"Topic to be processord\"\n message.body = \"New Topic is uploaded. Clic... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
sends notification for sign up confirmation | def notify_sign_up_confirmation!
UserMailer.sign_up_confirmation(self).deliver!
end | [
"def send_signup_notification\n deliver_activation_email(:signup, :subject => (MaSA[:activation_subject] || \"Please Activate Your Account\") )\n end",
"def send_signup_notification\n deliver_email(:signup, :subject => (MaSM[:activation_subject] || \"Please Activate Your Account\") ... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Resets single access token for user | def reset_single_access_token!
update_attribute(:single_access_token, User.encrypt_token(Time.now.to_i, "password reset--"))
end | [
"def reset_single_access_token!\n reset_single_access_token\n save_without_session_maintenance\n end",
"def clear_access_token\n update_access_token(nil)\n end",
"def flush_access_token!\n @access_token = nil\n end",
"def invalidate\n @access_token = n... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Scopes a block to the user's profile locale | def with_user_locale
raise "No block given" unless block_given?
begin
tmp_locale = I18n.locale
I18n.locale = profile.language
yield
ensure
I18n.locale = tmp_locale
end
end | [
"def l_scope(*sections, &block)\r\n ArkanisDevelopment::SimpleLocalization::Language.with_app_scope(*sections, &block)\r\n end",
"def l_scope(*sections, &block)\r\n ArkanisDevelopment::SimpleLocalization::Language.app_with_scope(*sections, &block)\r\n end",
"def l_scope(*sections, &block... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Checks if the type of the field is `NULLABLE`. | def nullable?
mode == "NULLABLE"
end | [
"def null?(field_info, field)\n field_info[\"notnull\"] == 1 && self.send(field).blank?\n end",
"def allow_null?\n !! @allow_null\n end",
"def not_null; end",
"def optional?(field)\n field.type.type_sym == :union &&\n field.type.schemas.first.type_sym == :null\n end... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Checks if the type of the field is `REPEATED`. | def repeated?
mode == "REPEATED"
end | [
"def repeated?\n label == Google::Protobuf::FieldDescriptorProto::Label::LABEL_REPEATED\n end",
"def refused_to_participate?\n !self.pr_recruitment_end_date.blank? && self.pr_recruitment_status_code == 2\n end",
"def were_fields_requested?; end",
"def reuse?\n props[:instance][:create] ==... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Updates the description of the field. | def description= new_description
@gapi.update! description: new_description
end | [
"def set_description(new_description)\r\n update(description: new_description)\r\n end",
"def update(description) # :nodoc:\n @description = description\n self\n end",
"def description=(value)\n @description = value\n end",
"def set_NewDescription(value)\n set_input(\"N... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Updates the mode of the field. | def mode= new_mode
@gapi.update! mode: verify_mode(new_mode)
end | [
"def set_Mode(value)\n set_input(\"Mode\", value)\n end",
"def mode=(new_mode)\n LOGGER.mode = new_mode\n end",
"def mode new_mode = nil\n data = mode_data()\n if new_mode\n data[:mode] = new_mode \n mode_data data\n end\n data[:mode]\n end",
"def mode=(val)\n if... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
The policy tag list for the field. Policy tag identifiers are of the form `projects//locations//taxonomies//policyTags/`. At most 1 policy tag is currently allowed. | def policy_tags
names = @gapi.policy_tags&.names
names.to_a if names && !names.empty?
end | [
"def node_policy_tags\n policy_tags = []\n if @policy_tags_enabled\n if @node.respond_to?('policy_group') && !@node.policy_group.nil?\n policy_tags << \"#{@scope_prefix}policy_group:#{@node.policy_group}\"\n end\n if @node.respond_to?('policy_name') && !@node.policy_name.nil?\n po... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Updates the policy tag list for the field. | def policy_tags= new_policy_tags
# If new_policy_tags is nil, send an empty array.
# Sending a nil value for policy_tags results in no change.
new_policy_tags = Array(new_policy_tags)
policy_tag_list = Google::Apis::BigqueryV2::TableFieldSchema::PolicyTags.new names: new_... | [
"def update_tag_list new_tag_listings\n\t\tnew_tags = new_tag_listings.split(' ')\n\t\t#drop tags that is not in the new list\n\t\tdropped_tags = self.tags.map{ |x| x.title } - new_tags\n\t\tself.tags.where{ title.in dropped_tags }.destroy_all\n\n\t\t#add tags that is in the new list\n\t\t(new_tags - self.tags.map{... | {
"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.