query stringlengths 7 9.5k | document stringlengths 10 1.07M | negatives listlengths 19 19 | metadata dict |
|---|---|---|---|
Description Opens the general page of the elements editor: the video icon redirects to VideoEditorControllernew the audio icon redirects to AudioEditorControllernew the image icon redirects to GalleriesControllerimage_for_image_editor (and successively to ImageEditorControlleredit) Mode Html | def new
render :layout => 'media_element_editor'
end | [
"def site_editor\n @browser.link(:text=>\"Site Editor\").click\n SiteEditor.new(@browser)\n end",
"def editorial_markup\r\n\t\r\n\tend",
"def set_elements\n super\n element(:title) {b.h2(:class => \"uif-headerText\").span}\n element(:submit_button) ... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Description Adds a link of this element to your section. found: reloads the element in compact mode compact: [this action doesn't occur] expanded: removes the element and reloads the whole page Mode Ajax + Json Specific filters ApplicationControllerinitialize_media_element ApplicationControllerinitialize_media_element_... | def add
@ok_msg = t('other_popup_messages.correct.add.media_element')
if @ok
if !current_user.bookmark('MediaElement', @media_element_id)
@ok = false
@error = I18n.t('activerecord.errors.models.bookmark.problem_creating_for_media_element')
end
else
@error = I18n.t('activere... | [
"def render_new_content_link(element)\n\t\t\t\tlink_to_overlay_window(\n\t\t\t\t\trender_icon('create') + t('add new content'),\n\t\t\t\t\talchemy.new_admin_element_content_path(element),\n\t\t\t\t\t{\n\t\t\t\t\t\t:size => '335x70',\n\t\t\t\t\t\t:title => t('Select an content'),\n\t\t\t\t\t\t:overflow => true\n\t\t... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Description Removes the link of this element from your section. found: reloads the element in compact mode compact: removes the element and reloads the whole page expanded: removes the element and reloads the whole page Mode Ajax + Json Specific filters ApplicationControllerinitialize_media_element ApplicationControlle... | def remove
@ok_msg = t('other_popup_messages.correct.remove.media_element')
if @ok
bookmark = Bookmark.where(:user_id => current_user.id, :bookmarkable_type => 'MediaElement', :bookmarkable_id => @media_element_id).first
if bookmark.nil?
@ok = false
@error = I18n.t('activerecord.erro... | [
"def remove_this_publication(main_title)\n target_div_id = self.text_field(:value=>main_title).parent.parent.parent.id\n self.div(:id=>target_div_id).button(:id=>/displayprofilesection_remove_link_/).click\n self.wait_for_ajax\n end",
"def remove_link\n # cocoon JS needs class specifically remove_fie... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Description Updates the general information of the element (title, description and tags) Mode Ajax Specific filters ApplicationControllerinitialize_media_element_with_owner_and_private | def update
if @ok
@media_element.title = params[:title]
@media_element.description = params[:description]
@media_element.tags = params[:tags_value]
@media_element.save_tags = true
if !@media_element.save
@errors = convert_media_element_error_messages @media_element.errors
... | [
"def update\n if @ok\n @media_element.title = params[:title]\n @media_element.description = params[:description]\n @media_element.tags = params[:tags]\n @media_element.save_tags = true\n if params[:is_public]\n @media_element.is_public = true\n @media_element.publication_da... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Gets media elements using Userown_media_elements | def get_own_media_elements
current_user_own_media_elements = current_user.own_media_elements(@page, @for_page, @filter)
@media_elements = current_user_own_media_elements[:records]
@pages_amount = current_user_own_media_elements[:pages_amount]
end | [
"def get_result_media_elements\n resp = current_user.search_media_elements(@word, @page, @for_page, @order, @filter)\n @media_elements = resp[:records]\n @pages_amount = resp[:pages_amount]\n @media_elements_amount = resp[:records_amount]\n @tags = []\n @tags = resp[:tags] if resp.has_key? :tags\n... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
GET /action_states GET /action_states.json | def index
@action_states = ActionState.all
end | [
"def get_states\n perform(:get, 'enum/states', nil, nonauth_headers).body\n end",
"def index\n @states = states.all\n json_response(@states)\n end",
"def states\n response = params[:name].present? ? State.search(params[:name].to_s) : @country.states\n render json: response\n ... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
POST /action_states POST /action_states.json | def create
@action_state = ActionState.new(action_state_params)
respond_to do |format|
if @action_state.save
format.html { redirect_to [project, @action_state], notice: 'Action state was successfully created.' }
format.json { render :show, status: :created, location: @action_state }
... | [
"def create\n state.attributes = state_params\n\n respond_to do |format|\n if state.save\n format.html { redirect_to admin_states_path, notice: 'State was successfully created.' }\n format.json { render :show, status: :created, location: state }\n else\n format.html { render :ne... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
PATCH/PUT /action_states/1 PATCH/PUT /action_states/1.json | def update
respond_to do |format|
if @action_state.update(action_state_params)
format.html { redirect_to [project, @action_state], notice: 'Action state was successfully updated.' }
format.json { render :show, status: :ok, location: @action_state }
end
end
end | [
"def update\n respond_to do |format|\n if @requests_state.update(requests_state_params)\n format.html { redirect_to @requests_state, notice: 'State was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: 'edit' }\n format.json { ... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
current_organisation returns organisation obj for current organisation return nil if no current organisation defined | def current_organisation()
begin
organisation = (
Thread.current[:organisation_id].blank? ?
nil :
Organisation.find( Thread.current[:organisation_id] )
)
return organisation
rescue ActiveRecord::RecordNotFound
return nil
end
end | [
"def organisation?\n current_organisation.present?\n end",
"def set_current_organisation( organisation )\n # able to handle organisation obj or organisation_id\n #case organisation\n # when Organisation then organisation_id = organisation.id\n # when Integer then organisation_id = or... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
current_organisation_id returns organisation_id for current organisation | def current_organisation_id()
return Thread.current[:organisation_id]
end | [
"def current_organisation()\n begin\n organisation = (\n Thread.current[:organisation_id].blank? ?\n nil :\n Organisation.find( Thread.current[:organisation_id] )\n )\n\n return organisation\n\n rescue ActiveRecord::RecordNotFound\n return nil\n ... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
set_current_organisation modellevel ability to set the current organisation NOTE: USE WITH CAUTION normally this should NEVER be done from the models ... it's only useful and safe WHEN performed at the start of a background job (DelayedJobperform) | def set_current_organisation( organisation )
# able to handle organisation obj or organisation_id
#case organisation
# when Organisation then organisation_id = organisation.id
# when Integer then organisation_id = organisation
# when Array then organisation_id = organisation
# el... | [
"def organisation_id=(new_organisation_id)\n unless self.can_change_org? || new_organisation_id.nil? || self.organisation.nil?\n # rip all permissions from the user\n self.roles.delete_all\n end\n # set the user's new organisation\n super(new_organisation_id)\n self.save!\n # rip api per... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
where_restrict_organisation gens organisation restrictive where clause for each klass NOTE: subordinate join tables will not get the default scope by Rails theoretically, the default scope on the master table alone should be sufficient in restricting answers to the current_organisation alone .. HOWEVER, it doesn't feel... | def where_restrict_organisation(*args)
args.map{|klass| "#{klass.table_name}.organisation_id = #{Thread.current[:organisation_id]}"}.join(" AND ")
end | [
"def where_restrict_tenant(*args)\n args.map { |klass| \"#{klass.table_name}.tenant_id = #{Thread.current[:tenant_id]}\" }.join(\" AND \")\n end",
"def where_restrict_account(*args)\n args.map{|klass| \"#{klass.table_name}.account_id = #{Thread.current[:account_id]}\"}.join(\" AND \")\n en... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Pass target to the scope handler of the specified type and name. If `name` is not specified then `:default` name is used. If `type` is not specified then we try to infer the type from the target class. | def apply_scope(target, type:, name: :default, scope_options: nil)
raise ActionPolicy::UnknownScopeType.new(self.class, type) unless
self.class.scoping_handlers.key?(type)
raise ActionPolicy::UnknownNamedScope.new(self.class, type, name) unless
self.class.scoping_handlers[type].key?... | [
"def bind_name(name, type)\n @names[name.to_sym] = type unless name.nil?\n end",
"def type_of(name)\n return @scope[name.to_sym][:type] if @scope[name.to_sym]\n @enclosing&.type_of(name)\n end",
"def method_missing(sym, *args, &block)\n target = if !block && args.empty? && sym =~ /^[... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Define scope type matcher. Scope matcher is an object that implements `===` (_case equality_) or a Proc. When no type is provided when applying a scope we try to infer a type from the target object by calling matchers one by one until we find a matching type (i.e. there is a matcher which returns `true` when applying i... | def scope_matcher(type, class_or_proc)
scope_matchers << [type, class_or_proc]
end | [
"def applies_type?(scope, type)\n !scope.key?(\"type\") || type&.to_sym.eql?(scope[\"type\"].to_sym)\n end",
"def applies_type?(scope, type); end",
"def scope_type=(value)\n @scope_type = value\n end",
"def type?(type)\n @scope.type?(type)\n end",
"def type_matcher(... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Main method for getting all Available TimeBlock(s) for a given date. +:base_time: DateTime used for determining the base scan date range. | def available_on(base_time)
# Stash this for future use, as we will be using it to set a
# baseline date in order to derive a bunch of different appointments
# from.
set_base_time(base_time)
# Fetch all TimeEntris related for this date query.
time_entries = time_entries_... | [
"def valid_blocks(base_time)\n set_base_time(base_time)\n time_entries = time_entries_for(base)\n end",
"def hotel_blocks_for_specific_date_range(start_date, end_date)\n specific_date_range = Hotel::DateRange.new(start_date, end_date)\n hotel_blocks_for_specific_date_range = hotel_blo... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Public api for returning all collisions for a given Range. The Range is transformed into a TimeBlock, and then pushed through the pipeline for natural detection of any collisions. | def collisions_for(range)
collider.detect TimeBlock.new(
start_time: range.begin,
end_time: range.end,
session: @session)
end | [
"def collisions\n @@collisions || {}\n end",
"def collide_hash_all(hash_rects)\n hash_rects.select { |key,value|\n value.collide_rect?+(self)\n }\n end",
"def collisions(rect)\n remain = visible_sprites(rect).to_a\n coll = remain.select { |item| item.intersect_rect? rect }\n ... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Return all valid TimeBlock(s) for a given base time. | def valid_blocks(base_time)
set_base_time(base_time)
time_entries = time_entries_for(base)
end | [
"def validate_time_blocks(time_blocks)\n b = time_blocks.select(&:collision_free?)\n\n # Test environment has unreliable data entry for start times.\n b = b.select(&:in_future?) unless Rails.env.test?\n\n b\n end",
"def half_hour_blocks( time_start, time_end )\n # Parse time to... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Returns all valid Appointments for a given base time. | def valid_appointments(base_time)
transform_blocks_to_appointments(valid_blocks(base_time))
end | [
"def appointments_with_times_only_for_public_scheduler\n self.appointments.map{ |appt| {id: appt.id, start_time: appt.start_time, status: appt.status}}\n end",
"def available_on(base_time)\n # Stash this for future use, as we will be using it to set a\n # baseline date in order to derive a bunch... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Get all TimeEntry(s) that match the current session properties. +:target_date+ A DateTime to base the TimeEntry collection query from. | def time_entries_for(target_date)
target_day = Skej::NLP.parse(session, target_date.to_s)
.strftime('%A')
.downcase
.to_sym
TimeEntry.where(build_query_params).with_day(target_day).map do |entry|
entry.se... | [
"def time_entries\n get_ticket_property_list(\"time_entries\" , Unfuddled::TimeEntry)\n end",
"def entries\n settings.time_entries.present? ? settings.time_entries : []\n end",
"def time_entries(range_start = nil, range_end = nil)\n options = {}\n\n options = {\"range_start\" =>\n ran... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Produces TimeSlot(s) from a collection of TimeEntries | def generate_time_slots(time_entries)
time_entries.map { |entry| extract_available_slots(entry) }.flatten
end | [
"def time_entries(options = {})\n entries = []\n time_invested(options).groups.each { |g| entries << g[\"time_entries\"] }\n\n process_list_response( entries.flatten , Unfuddled::TimeEntry )\n end",
"def days_from_timeslot_matches(timeslots_container, day_with_hours)\n resul... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Responsible combining a collection of slots into common groups, defined by touching boundaries. +:slots: Array / Collection of TimeSlot(s) | def combine_linear_slots(slots)
last_slot = false
end_time = false
start_time = false
flushed = false # Tracks the current continuity chain
count = 0
aggregate = []
debug = []
slots.sort_by(&:start_time).each_with_index do |slot, i|
... | [
"def unavailable_slots(sport, start_time, end_time, free_for_coach_id = nil)\n free_for_coach_id = free_for_coach_id.to_i\n sport_courts = if sport.present?\n courts.for_sport(sport)\n elsif free_for_coach_id > 0\n courts.for_sport(Coach.find(free_for_coach_id).sports)\n else\n courts\n ... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Given a collection of TimeBlock(s), return only the ones that have no detectable collisions (and thus are valid). +:time_blocks+ All extracted TimeBlock(s) you wish to have validated. | def validate_time_blocks(time_blocks)
b = time_blocks.select(&:collision_free?)
# Test environment has unreliable data entry for start times.
b = b.select(&:in_future?) unless Rails.env.test?
b
end | [
"def valid_blocks(base_time)\n set_base_time(base_time)\n time_entries = time_entries_for(base)\n end",
"def invalid_blocks\n\t\treturn self.chain.reject( &:valid? )\n\tend",
"def valid_schedule?(time_blocks)\n time_blocks = quicksort_timeblocks(time_blocks)\n return !exists_overlap?(ti... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Given a collection of TimeBlock(s), return a more optimized subset of the given collection. +:time_blocks: Collection of TimeBlock(s) to be filtered and optimized. | def optimize_time_blocks(time_blocks)
Optimizer.new.optimize(time_blocks)
end | [
"def quicksort_timeblocks(time_blocks)\n if (time_blocks.size <= 1)\n return time_blocks\n end\n\n pivot = time_blocks[0]\n left = []\n right = []\n\n time_blocks[1..time_blocks.size-1].each do |tb|\n if (tb.term.to_i < pivot.term.to_i)\n left.push(tb)\n elsif (pivot.term.to_... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
The size of a TimeBlock. Based on the minute duration of the chosen Service. | def block_size
session.chosen_service.duration rescue session.business.services.first.duration
end | [
"def size_time\n\t\t\t\t\tif !scheduled?\n\t\t\t\t\t\traise \"Schedule event to specific date first.\"\n\t\t\t\t\tend\n\t\t\t\t\tif @size.nil?\n\t\t\t\t\t\t@size = DateTime.parse(\"2000-01-01 00:00:00 +0000\")\n\t\t\t\t\t\tself.reservations.each do |reservation|\n\t\t\t\t\t\t\tif reservation.above_line?\n\t\t\t\t\t... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Fetch the timezone for the chosen office. While also memoizing the time_zone result as | def time_zone
return @time_zone_cache if @time_zone_cache
# Get the office id from the session json store
id = @session.store[:chosen_office_id]
office = Office
.where(business_id: @session.business_id, id: id)
.first
if office.present?
@time_zone_... | [
"def time_zone\n @session.chosen_office.time_zone if @session.chosen_office.present?\n end",
"def tz_timezone ; @venue.tz_timezone; end",
"def timezone\n TimeZoneHelper.info_hash(tzinfo_tz, rails_tz)\n end",
"def tz\n # logger.debug(\"CHC: customer tz called from #{caller.join(\"\\n\")}\"... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Add a random amount of blocks (30min per block) to the end of an existing start. | def random_range_end(start)
start + (rand(1..5) * 30).minutes
end | [
"def add_for_num_blocks(words)\n # We just add to the single block, and we split this when we call\n # #blocks\n @single_block += words\n end",
"def refresh_offset\n 300 + rand(0..60)\n end",
"def generate_blocks (map)\n blocks = 0\n while blocks < $NUM_BLOCKS\n rand... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
add hvac Add the daylighting controls for lobby, cafe, dinning and banquet | def add_daylighting_controls(building_vintage)
space_names = ['Banquet_Flr_6','Dining_Flr_6','Cafe_Flr_1','Lobby_Flr_1']
space_names.each do |space_name|
space = self.getSpaceByName(space_name).get
space.addDaylightingControls(building_vintage, false, false)
end
end | [
"def addDaylightingControls()\n \n OpenStudio::logFree(OpenStudio::Info, 'openstudio.model.Model', 'Started adding daylighting controls.')\n \n # Add daylighting controls to each space\n self.getSpaces.sort.each do |space|\n added = space.addDaylightingControls(self.template, false, false)\n ... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Generate a planet based on user's inputs | def generate_planet
puts "\nLet's create a planet from scratch."
print "Please enter its name first: "
name = gets.chomp
print "What's its diameter of this planet in km? "
diameter = gets.chomp.to_f
print "What's its mass in kg? (example of input format: 3.30 x 10^23 ) "
mass = gets.chomp
print "What's ... | [
"def build_planet()\n puts \"\\nAdding planet. Please tell me more about this planet.\"\n \n print \"Enter the planet name: \"\n name = gets.chomp.capitalize\n \n print \"\\nEnter the planet color: \"\n color = gets.chomp.downcase\n \n print \"\\nEnter planet mass in kg: \"\n mass_kg =... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
def decimal_base(n) ten_to_position = 1 loop do n = 1 break if n == 0 ten_to_position = 10 end ten_to_position end | def decimal_base(n)
10**(n-1)
end | [
"def super_digit(n)\n\n # return n for all one digit n values \n if n < 10\n return n\n end\n\n # add each digit, peeling of last one in place each time\n return super_digit(n % 10 + super_digit(n/10))\n\nend",
"def super_digit(n)\n while n > 9\n n = n % 10 + super_digit(n / 10)\n end\n return n\nen... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Sets the acceleration of a stepper, in (micro)steps per second squared, or raises an error. | def acceleration=(new_acceleration)
Klass.setAcceleration(@handle, @index, new_acceleration.to_f)
new_acceleration
end | [
"def setAcceleration(acceleration)\n @acceleration = acceleration\n end",
"def accelerate(new_speed)\n @speed = new_speed\n end",
"def set_acceleration(acceleration)\n send_request(FUNCTION_SET_ACCELERATION, [acceleration], 'S', 0, '')\n end",
"def acceleration=(value)\r\n if value.is_a... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Sets the current position of a stepper, in (micro)steps, or raises an error. | def current_position=(new_current_position)
Klass.setCurrentPosition(@handle, @index, new_current_position.to_i)
new_current_position
end | [
"def current_step=(value)\n @current_step = value\n end",
"def next_step!\n self.stepper_current_step = self.next_step\n self\n end",
"def stepper_target=(position)\n\t\t\t\traise ArgumentError.new \"Position must be an integer\" unless position.is_a? Fixnum\n\n\t\t\t\twrite(0x41, [positi... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Sets the engaged state of the Phidget. | def engaged=(new_state)
tmp = new_state ? 1 : 0
Klass.setEngaged(@handle, @index, tmp)
new_state
end | [
"def set_gstate\n @p.set_gstate(self)\n end",
"def put_hat_on\n self.hat_state = true\n end",
"def set_state(is_on)\n @client.set_state(is_on)\n end",
"def thing_state=(value)\n @children['thing-state'][:value] = value\n end",
"def enter_in_using_skill_state\n... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Sets the target position of a stepper, in (micro)steps, or raises an error. | def target_position=(new_target_position)
Klass.setTargetPosition(@handle, @index, new_target_position.to_i)
new_target_position
end | [
"def stepper_target=(position)\n\t\t\t\traise ArgumentError.new \"Position must be an integer\" unless position.is_a? Fixnum\n\n\t\t\t\twrite(0x41, [position].pack(\"l>\"))\n\t\t\tend",
"def setup_move_to_target\n return unless PONY::ERRNO.check_sequence(current_act)\n stop_all_movements\n xpos = target.... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Sets the velocity limit of a stepper, in (micro)steps per second, or raises an error. | def velocity_limit=(new_velocity_limit)
Klass.setVelocityLimit(@handle, @index, new_velocity_limit.to_f)
new_velocity_limit
end | [
"def velocity_limit=(new_velocity_limit)\n Klass.setVelocityLimit(@handle, @index, new_velocity_limit.to_f)\n new_velocity_limit\n end",
"def setVelocity(velocity)\n @velocity = velocity\n end",
"def limit(velocity_limit)\r\n velocity_norm = @velocity.norm\r\n if velocity_norm > veloc... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Create a NxN grid of points on a face of the cube. Note that this will generate (N+1)(N+1) points. Each point is projected on the sphere and stored in an array. Note that all these are points on the unit sphere, and so their distance to the origin is 1, and so each point can be used as its own normal. | def grid(face, n)
dx = 2.0/n
dy = 2.0/n
a = Array.new
n += 1
n.times do |j|
y = -1.0 + j*dy
n.times do |i|
x = -1.0 + i*dx
lon, lat = QuadSphere::CSC.inverse(face, x, y)
sx = Math::cos(lat) * Math::cos(lon)
sy = Math::cos(lat) * Math::sin(lon)
sz ... | [
"def grid\n (0...@height).map do |y|\n (0...@width).map do |x|\n yield cube(x,y)\n end\n end\n end",
"def points_to_grid(points, width, height, zeroItem = 0, oneItem=1)\n grid = Grid.new(width, height, zeroItem) \n points.each {|point| grid[int_point(point)] = oneItem} ... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
p grid(0, 3) Create triangle strips to represent a NxN mesh. The given array should then contain (N+1)2 points, arranged as N+1 rows of N+1 points. | def mesh2strips(n,a)
dx = 2.0/n
dy = 2.0/n
row = n+1
n.times do |j|
glBegin(GL_TRIANGLE_STRIP)
rowi = j*row
row.times do |x|
add_vertex(a[rowi+x])
add_vertex(a[rowi+row+x])
end
glEnd
end
end | [
"def grid(n, m)\n Array.new(n) { Array.new(m) }\nend",
"def grid(face, n)\n dx = 2.0/n\n dy = 2.0/n\n a = Array.new\n n += 1\n\n n.times do |j|\n y = -1.0 + j*dy\n n.times do |i|\n x = -1.0 + i*dx\n lon, lat = QuadSphere::CSC.inverse(face, x, y)\n sx = Math::cos(lat)... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Set client stats details Author: Puneet Date: 02/02/2018 Reviewed By: | def set_client_stats(client_stats_data)
@client_stats = CompanyApi::Response::Entity::ClientStats.new(client_stats_data)
end | [
"def populate_client_usage(client)\n client_id = client.id\n registration_count = User.using_client_shard(client: client).where(client_id: client_id).count\n kyc_submissions_count = UserKycDetail.using_client_shard(client: client).\n where(client_id: client_id).sum(:submission_count)\n\n ... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Set Client BT Addresss Data Author: Puneet Date: 02/02/2018 Reviewed By: | def set_client_bt_addresses_data(client_bt_addresses_data)
@client_bt_addresses = CompanyApi::Response::Entity::ClientBrandedTokenAddresses.new(client_bt_addresses_data)
end | [
"def set_Address(value)\n set_input(\"Address\", value)\n end",
"def set_address(new_address)\r\n update(address: new_address)\r\n end",
"def update_contact_info txn\n AddressManager::set_user_address txn.user, txn\n end",
"def set_address(new_address)\n update(address: new_address)... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
get(Symbol) method that returns a node by the id returns | def get id
@nodes[id]
end | [
"def get_node(id)\n @nodes[id.to_i]\n end",
"def get_node(id)\n get_object('node', id)\n end",
"def get_node(id)\n get_object('node', id)\n end",
"def get_one(id)\n data = @adapter.get_one(@href, id)\n data.nil? ? nil : Node.resolve(@adapter, @conf... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
connect(Edge) method that adds a connection to the list of nodes returns | def connect edge
self.add edge.src
self.add edge.dst
@nodes[edge.src] << edge
edge
end | [
"def connect_over(node); end",
"def connect_via(edge)\n if edge.to == self && ! slots.in.include?(edge.label)\n slots.in.add(edge.label)\n end\n\n if edge.from == self && ! slots.out.include?(edge.label)\n slots.out.add(edge.label)\n end\n\n super\n end",
"def connect_t... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
path_number(List, Symbol, Hash, String) return the number of paths with in the limits returns | def path_number visit_path, dst, limits, condition=EG
paths = route(visit_path, dst, limits, condition)
select_condition = condition == EG ? EG : condition == UNTIL ? LESS : UNTIL
return (paths.select {|path| eval final_eval( select_condition, limits )}).length
end | [
"def path_count(*args)\n path_rels(*args).size\n end",
"def path_captures\n return 0 unless conditions[:path]\n Behavior.count_parens_up_to(conditions[:path], conditions[:path].size)\n end",
"def number_of_paths(n)\n return 0 if n < 0\n return 1 if n == 1 || n == 0\n number_of_paths(n ... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
step_number(Hash, String) return the eval expression for the conditions returns | def final_eval condition, limits
return "#{condition[:steps]}#{limits[:steps]}" if limits.has_key? :steps
return "#{condition[:cost]}#{limits[:cost]}" if limits.has_key? :cost
false
end | [
"def first_step_nr\n first_step[\"step\"]\n end",
"def step\n read_attribute(:step) or ( input and input.step )\n end",
"def step_state(number)\n s = @step_states[number] if @step_states[number]\n return s\n end",
"def step_result; end",
"def steps(n)\nend",
"def input_step(step_value... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Returns the account for this business linked to a "money" program with is_money == true | def cashbox
return @cashbox if @cashbox.present?
return nil unless has_money_program?
@cashbox = self.accounts.where(:program_id => money_program.id, :is_money => true).first
end | [
"def payable_account\n payable_account = self.accounts.where(:type=>'payable').first\n payable_account\n end",
"def payment_entry\n business_account.entries.find { |e|\n e.code == number.to_s and not e.accounts.include? commodity_account\n }\n end",
"def get_account_from(descrip... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Tries to detect the current processor based if any of the processors exist. Mogrify have precedence over gm by default. === Returns [String] The detected procesor | def choose_processor
self.processor = if MiniMagick::Utilities.which('mogrify')
:mogrify
elsif MiniMagick::Utilities.which('gm')
:gm
else
nil
end
end | [
"def choose_processor\n if `type -P mogrify`.size > 0\n return\n elsif `type -P gm`.size > 0\n self.processor = \"gm\"\n end\n end",
"def gm?\n choose_processor if processor.nil?\n\n return processor.to_s.downcase.to_sym == :gm unless processor.nil?\n false\n end"... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Discovers the imagemagick version based on mogrify's output. === Returns The imagemagick version | def image_magick_version
@@version ||= Gem::Version.create(`mogrify --version`.split(' ')[2].split('-').first)
end | [
"def exiftool_version\n @exiftool_version ||= `#{exiftool_command} -ver`.to_f\n end",
"def imagemagick7?; end",
"def valid_version_installed?\n image_magick_version >= minimum_image_magick_version\n end",
"def version\n Gem.loaded_specs['image_optim'].version.to_s\n rescue\n 'DEV'... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
The minimum allowed imagemagick version === Returns The minimum imagemagick version | def minimum_image_magick_version
@@minimum_version ||= Gem::Version.create('6.6.3')
end | [
"def valid_version_installed?\n image_magick_version >= minimum_image_magick_version\n end",
"def image_magick_version\n @@version ||= Gem::Version.create(`mogrify --version`.split(' ')[2].split('-').first)\n end",
"def os_minimum_version\n return @os_minimum_version\n ... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Checks whether the imagemagick's version is valid === Returns [Boolean] | def valid_version_installed?
image_magick_version >= minimum_image_magick_version
end | [
"def valid?\n versions.any?\n end",
"def invalid?\n %w(undefined 0).include?(version.to_s)\n end",
"def valid_version?(version)\n version =~ /\\d+\\.\\d+\\.\\d+(\\.(alpha|beta|rc)(\\.\\d+)?)?/\nend",
"def valid?\n run_command(\"identify\", @path)\n true\n rescue MiniMagick::Inval... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Picks the right processor if it isn't set and returns whether it's mogrify or not. === Returns [Boolean] | def mogrify?
choose_processor if processor.nil?
return processor.to_s.downcase.to_sym == :mogrify unless processor.nil?
false
end | [
"def gm?\n choose_processor if processor.nil?\n\n return processor.to_s.downcase.to_sym == :gm unless processor.nil?\n false\n end",
"def choose_processor\n if `type -P mogrify`.size > 0\n return\n elsif `type -P gm`.size > 0\n self.processor = \"gm\"\n end\n end"... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Picks the right processor if it isn't set and returns whether it's graphicsmagick or not. === Returns [Boolean] | def gm?
choose_processor if processor.nil?
return processor.to_s.downcase.to_sym == :gm unless processor.nil?
false
end | [
"def choose_processor\n self.processor = if MiniMagick::Utilities.which('mogrify')\n :mogrify\n elsif MiniMagick::Utilities.which('gm')\n :gm\n else\n nil\n end\n end",
... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Returns a Project object identified by given string The following identifiers are accepted /gdc/md/ /gdc/projects/ | def [](id, options = {})
return id if id.respond_to?(:project?) && id.project?
if id == :all
Project.all
else
if id.to_s !~ %r{^(\/gdc\/(projects|md)\/)?[a-zA-Z\d]+$}
fail(ArgumentError, 'wrong type of argument. Should be either project ID or path')
end
... | [
"def [](id)\n if id.to_s !~ /^(\\/gdc\\/(projects|md)\\/)?[a-zA-Z\\d]+$/\n raise ArgumentError.new(\"wrong type of argument. Should be either project ID or path\")\n end\n\n id = id.match(/[a-zA-Z\\d]+$/)[0] if id =~ /\\//\n\n response = GoodData.get PROJECT_PATH % id\n P... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Gets author of project | def author
# TODO: Return object instead
@json['project']['meta']['author']
end | [
"def author\n @author ||= run 'git config --get user.name'\n end",
"def get_author()\n return @author\n end",
"def author\n @author || 'Unknown'\n end",
"def author\n return @author\n end",
"def author\n file.version.author.name\n end",
... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Gets ruby wrapped raw project JSON data | def data
raw_data['project']
end | [
"def getProject(projectName)\n data = CLIENT.repository(projectName)\n return data\nend",
"def get_project_info(project, all_data = true)\n result = @client.api_helper.get_response(Config::TODOIST_PROJECTS_GET_COMMAND, {project_id: project.id, all_data: true})\n \n project = resul... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Deletes dashboards for project | def delete_dashboards
Dashboard.all.map { |data| Dashboard[data['link']] }.each { |d| d.delete }
end | [
"def delete_dashboards\n Dashboard.all.map { |data| Dashboard[data['link']] }.each(&:delete)\n end",
"def destroy\n return render_not_found('dashboard') unless dashboard\n authorize! :destroy_impac_dashboards, dashboard\n\n if dashboard.destroy\n MnoEnterprise::EventLogger.info('dashboard_de... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Gets project role byt its summary | def get_role_by_summary(role_summary, role_list = roles)
role_list.each do |role|
return role if role.summary.downcase == role_summary.downcase
end
nil
end | [
"def summary\n @json['projectRole']['meta']['summary']\n end",
"def get_role user\n project_role_user = ProjectRoleUser.where(:project_id => self, :user_id => user).first\n if project_role_user\n project_role_user.role.name\n else\n nil\n end\n end",
"def role_for_user(user)\n ... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Returns invitations to project | def invitations
res = []
tmp = GoodData.get @json['project']['links']['invitations']
tmp['invitations'].each do |invitation|
res << GoodData::Invitation.new(invitation)
end
res
end | [
"def invitations\n invitations = client.get @json['project']['links']['invitations']\n invitations['invitations'].pmap do |invitation|\n client.create GoodData::Invitation, invitation\n end\n end",
"def invitations\n @title = \"Invitaciones\"\n @invitations = GetInvitationsForUser.c... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Checks if this object instance is project | def project?
true
end | [
"def is_for_project?\n not self.project.nil?\n end",
"def project?\n course_type_name == \"project\"\n end",
"def has_project?\n !project_id.nil? && project.visible\n end",
"def belongs_to_project?(project)\n (source_type == \"project\") &&\n (project_id == project.id)\n end",
"def proj... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Gets project update date | def updated
DateTime.parse(@json['project']['meta']['updated'])
end | [
"def updated_at\n Time.parse(github_repo_info['updated_at'])\n end",
"def updated_for_repo(repo)\n repo.updated_at.iso8601\n end",
"def update_project_time\n self.project.update_project_time\n end",
"def updated_date_time\n return @updated_date_time\n end",
"def... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Run validation on project Valid settins for validation are (default all): ldm Checks the consistency of LDM objects. pdm Checks LDM to PDM mapping consistency, also checks PDM reference integrity. metric_filter Checks metadata for inconsistent metric filters. invalid_objects Checks metadata for invalid/corrupted object... | def validate(filters = %w(ldm, pdm, metric_filter, invalid_objects))
response = GoodData.post "#{GoodData.project.md['validate-project']}", 'validateProject' => filters
polling_link = response['asyncTask']['link']['poll']
polling_result = GoodData.get(polling_link)
while polling_result['wTaskSta... | [
"def validate(filters = %w(ldm pdm metric_filter invalid_objects))\n response = GoodData.post \"#{GoodData.project.md['validate-project']}\", 'validateProject' => filters\n polling_link = response['asyncTask']['link']['poll']\n GoodData.poll_on_response(polling_link) do |body|\n body['wTaskSta... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
retrieve market id get market id from Vendor classfile match up market id and vendor id provide a collection of all vendor instances associated with market by id | def vendors ##DON'T NEED TO PASS IN AN ARGUMENT JUST THE VALUE FROM THE ARGUMENT!!!!
# lookup every vendor that matches this market id
FarMar::Vendor.by_market(@id)
##OMG YAY, REMEMBER THIS TO BRING IN CLASSES FOR DIFFERENT METHODS,
##bring in class object and method and pass in the id from market
end | [
"def vendors\n FarMar::Vendor.all.find_all {|instance| instance.market_id == id}\n end",
"def vendors\n FarMar::Vendor.by_market(id)\n end",
"def vendors(market_id)\n FarMar::Vendor.all.select { |vendor| vendor.market_id == market_id }\n end",
"def vendors\n return FarMar::Vendor.by_market(... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Elect a primary server within this topology. | def elect_primary(description, servers); self; end | [
"def elect_primary!(description)\n @topology = topology.elect_primary(description, servers_list)\n end",
"def elect_primary(description, servers)\n if description.replica_set_name == replica_set_name\n unless detect_stale_primary!(description)\n servers.each do |server|\n ... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Sharded topologies have no replica set name. | def replica_set_name; nil; end | [
"def replica_set?; false; end",
"def replica_set?\n type == Mongo::Cluster::Topology::ReplicaSetNoPrimary ||\n type == Mongo::Cluster::Topology::ReplicaSetWithPrimary\n end",
"def reconfiguring_replica_set?\n err = details[\"err\"] || details[\"errmsg\"] || details[\"$err\"] || \... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
A sharded topology is sharded. | def sharded?; true; end | [
"def shard_swapping_prohibited?; end",
"def sharded?\n $mongo_client ||= initialize_scanned_client!\n $sharded ||= ($mongo_client.cluster.sharded? || single_mongos?)\nend",
"def set_sharding\n Rails.application.config.allow_sharding = params[:state]\n render :get_sharding\n end",
"def needs... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Creates a new version of the app in HockeyApp. | def create_version
Milkrun.say "Creating new version of app in HockeyApp"
body = {}.tap do |json|
json[:bundle_version] = version_code
json[:bundle_short_version] = version_name
json[:status] = 1
end
headers = {}.tap do |h|
h["X-HockeyAppToken"] = token
... | [
"def make_version\n version = HockeyApp::Version.new(app, client)\n version.notes = self.notes\n version.notes_type = HockeyApp::Version::NOTES_TYPES_TO_SYM.invert[self.notes_type]\n version.notify = HockeyApp::Version::NOTIFY_TO_BOOL.invert[self.notify]\n version.status = HockeyApp::Version::STATUS_... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Whether the environment is valid for this provider. | def valid?
env_keys.all? { |k| env.key?(k) }
end | [
"def valid_for_environment?\n current_env = ENV['RAILS_ENV']\n self.environment.nil? || current_env.nil? || self.environment.split(/,/).include?(current_env)\n end",
"def validate_envs?()\n\t\tenv = @options[:env]\n\n\t\tres = subset?([env], @envs_list)\n\t\tif ! res\n\t\t\tputs \"Environment #{env}, is no... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
GET /people_tasks GET /people_tasks.json | def index
@people_tasks = TasksPerson.all
respond_to do |format|
format.html # index.html.erb
format.json { render json: @people_tasks }
end
end | [
"def show\n @tasks_person = TasksPerson.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @tasks_person }\n end\n end",
"def index\n @resource_in_tasks = @task.resource_in_tasks\n\n respond_to do |format|\n format.html # index.ht... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
GET /people_tasks/1 GET /people_tasks/1.json | def show
@tasks_person = TasksPerson.find(params[:id])
respond_to do |format|
format.html # show.html.erb
format.json { render json: @tasks_person }
end
end | [
"def index\n @people_tasks = TasksPerson.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @people_tasks }\n end\n end",
"def show\n @task = Task.find(params[:id])\n render json: @task\n end",
"def show\n @task = Task.find(params[:id])\n\n ... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
GET /people_tasks/new GET /people_tasks/new.json | def new
@tasks_person = TasksPerson.new
respond_to do |format|
format.html # new.html.erb
format.json { render json: @tasks_person }
end
end | [
"def new\n @task = tasks.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @task }\n end\n end",
"def new\n @task = @user.tasks.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @task }\n end\n en... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
POST /people_tasks POST /people_tasks.json | def create
@tasks_person = TasksPerson.new(params[:tasks_person])
respond_to do |format|
if @tasks_person.save
format.html { redirect_to @tasks_person, notice: 'Tasks person was successfully created.' }
format.json { render json: @tasks_person, status: :created, location: @tasks_person }
... | [
"def create\n #@task = Task.new(task_params)\n task = @task_list.tasks.create!(task_params)\n render json: task\n end",
"def staff_post_task\n staff = params[:user_id].present? ? User.where(:id => params[:user_id]).first : current_user\n tasks = staff.tasks.map{|t| {\n id: t.id, \n ... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
PUT /people_tasks/1 PUT /people_tasks/1.json | def update
@tasks_person = TasksPerson.find(params[:id])
respond_to do |format|
if @tasks_person.update_attributes(params[:tasks_person])
format.html { redirect_to @tasks_person, notice: 'Tasks person was successfully updated.' }
format.json { head :no_content }
else
format.... | [
"def update\n @project = Project.find(params[:project_id])\n @task = @project.tasks.find(params[:id])\n\n respond_to do |format|\n if @task.update_attributes(params[:task])\n format.html { redirect_to([@task.project, @task], :notice => 'Task was successfully updated.') }\n format.json { ... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
DELETE /people_tasks/1 DELETE /people_tasks/1.json | def destroy
@tasks_person = TasksPerson.find(params[:id])
@tasks_person.destroy
respond_to do |format|
format.html { redirect_to people_tasks_url }
format.json { head :no_content }
end
end | [
"def destroy\n @personal_task = PersonalTask.find(params[:id])\n @personal_task.destroy\n\n respond_to do |format|\n format.html { redirect_to personal_tasks_url }\n format.json { head :ok }\n end\n end",
"def destroy\n @action_task = ActionTask.find(params[:id])\n @action_task.destro... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Updates the jira web.xml file with the soulwing (CAS library) authentication configuration | def config_web_xml()
web_xml = File.readlines(self.web_xml()).map do |line|
if line =~ /#{web_xml_token}/
template = File.open("#{DEPLOYER_HOME}/resources/jira_cas_web.xml") { |f| f.read() }
line + ERB.new(template).result(self.send(:binding))
else
line
end
... | [
"def do_auth\r\n send_request_cgi({\r\n 'uri' => normalize_uri(target_uri.path.to_s, 'login.jsp'),\r\n 'method' => 'POST',\r\n 'cookie' => \"atlassian.xsrf.token=#{@xsrf_token}; #{@session_id}\",\r\n 'vars_post' => {\r\n 'os_username' => datas... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Shortcut to jira entityengine.xml file | def entityengine_xml()
"#{self.build_dir()}/src/edit-webapp/WEB-INF/classes/entityengine.xml"
end | [
"def config_entityengine_xml()\n ee_xml = File.readlines(self.entityengine_xml()).map do |line|\n if m = /(#{Regexp.quote(self.entityengine_xml_db_token())})/.match(line)\n self.debug(m[0])\n new_str = \"#{m.pre_match}#{entityengine_db}#{m.post_match}\"\n self.debug(new_str)\n... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Updates the jira entityengine.xml file with the correct database configs | def config_entityengine_xml()
ee_xml = File.readlines(self.entityengine_xml()).map do |line|
if m = /(#{Regexp.quote(self.entityengine_xml_db_token())})/.match(line)
self.debug(m[0])
new_str = "#{m.pre_match}#{entityengine_db}#{m.post_match}"
self.debug(new_str)
new... | [
"def update_db\n require \"../conf/db_schema.rb\"\n Knj::Db::Revision.new.init_db(\"debug\" => false, \"db\" => @db, \"schema\" => Openall_time_applet::DB_SCHEMA)\n end",
"def update_db\n require \"#{File.dirname(__FILE__)}/../conf/db_schema.rb\"\n Knj::Db::Revision.new.init_db(\"debug\" => false, \"... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Shortcut to jira seraphconfig.xml file | def seraph_config_xml()
"#{self.build_dir()}/src/webapp/WEB-INF/classes/seraph-config.xml"
end | [
"def seraph_config_xml()\n \"#{build_dir}/src/confluence/WEB-INF/classes/seraph-config.xml\"\n end",
"def config_seraph_config_xml()\n seraph_xml = File.readlines(self.seraph_config_xml)\n \n seraph_xml = seraph_xml.map do |line|\n if m = /(#{Regexp.quote(seraph_config_xml_token)})/.... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Updates the jira seraph_config.xml file with the soulwing authenticator. | def config_seraph_config_xml()
seraph_xml = File.readlines(self.seraph_config_xml()).map do |line|
if m = /(#{Regexp.quote(self.seraph_config_xml_auth_class_token())})/.match(line)
self.debug(m[0])
new_str = "#{m.pre_match}#{self.cas_authenticator_class()}#{m.post_match}"
sel... | [
"def config_seraph_config_xml()\n seraph_xml = File.readlines(self.seraph_config_xml)\n \n seraph_xml = seraph_xml.map do |line|\n if m = /(#{Regexp.quote(seraph_config_xml_token)})/.match(line)\n debug(m[0])\n debug(\"#{m.pre_match}#{cas_authenticator_class}#{m.post_match}\"... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Shortcut to jiraapplication.properties file | def jira_application_properties()
"#{self.build_dir()}/src/edit-webapp/WEB-INF/classes/jira-application.properties"
end | [
"def config_jira_application_properties()\n jira_props = File.readlines(self.jira_application_properties()).map do |line|\n if m = /(#{Regexp.quote(jira_home_token)})/.match(line)\n self.debug(m[0])\n new_str = \"#{self.jira_home_token()} #{self.data_dir()}\"\n self.debug(new_... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Sets the jira.home property in the file: jiraapplication.properties. | def config_jira_application_properties()
jira_props = File.readlines(self.jira_application_properties()).map do |line|
if m = /(#{Regexp.quote(jira_home_token)})/.match(line)
self.debug(m[0])
new_str = "#{self.jira_home_token()} #{self.data_dir()}"
self.debug(new_str)
... | [
"def set_workspace_home\n begin\n if not (workspace_home = ENV['WORKSPACE_HOME'] )\n workspace_home = Dor::Config.robots.workspace\n end\n rescue NameError => e\n LyberCore::Log.fatal(\"WORKSPACE_HOME is undefined. Do you need to set it in your config file?\")\n ... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Places IST banner jpg in imaages directory | def config_ist_banner()
FileUtils.cp("#{UcbDeployer::RESOURCES_DIR}/ist_banner.jpg",
"#{self.build_dir()}/src/webapp/images/")
end | [
"def anaura_bay_image_path\n File.expand_path( \"../anaura_bay.jpg\", __FILE__ )\nend",
"def banner_path\n path = @path[0...@path.length - 4] + '_banner.png'\n path_remote = @path_remote[0...@path_remote.length - 4] + '_banner.png'\n File.exists?(path) ? path_remote : 'https://maps.avicus.net' + '/defau... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Remove jars from WEBINF/lib that have been installed at the container level to avoid conflicts. | def reshuffle_jars()
FileUtils.mkdir_p("#{self.build_dir()}/src/edit-webapp/WEB-INF/lib/")
FileUtils.cp(Dir["#{UcbDeployer::RESOURCES_DIR}/soulwing-casclient-*"],
"#{self.build_dir()}/src/edit-webapp/WEB-INF/lib/")
# These have been placed in $CATALINA_HOME/lib
["mail", "activ... | [
"def reshuffle_jars()\n FileUtils.cp(Dir[\"#{UcbDeployer::RESOURCES_DIR}/soulwing-casclient-*\"],\n \"#{build_dir}/src/confluence/WEB-INF/lib/\")\n # Remove the jars that are installed at the container level\n [\"postgresql\", \"activation\", \"mail\"].each do |jar|\n FileUti... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Switch Roles! Print 10 Write a method, array_print_10, that puts the numbers 0 9 using an array and the each method | def array_print_10
end | [
"def array_print_10\n [0, 1, 2, 3, 4, 5, 6, 7, 8, 9].each do |n|\n puts n\n end\nend",
"def print_array(array)\n (length(array)).times do |i|\n print array[i]\n end\n # raise NotImplementedError\nend",
"def print_array(array)\n length(array).times do |index|\n puts array[index]\n end\n # raise ... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Write a method, range_print_10, that prints the numbers 0 9 using a range and the each method | def range_print_10
end | [
"def range_print_10\n (0..9).each do |n|\n puts n\n end\nend",
"def range_print_10\n (0..9).step(1) do |n| \n puts n \n end \n \nend",
"def integer_print_10\nend",
"def integer_print_10\n 10.times{|x| print x}\nend",
"def integer_print_10\n\n 10.times {|i| p i}\nend",
"def integer_print_10\n ... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Write a method, integer_print_10, that prints the numbers 0 9 using an integer and the times method | def integer_print_10
end | [
"def integer_print_10\n 10.times{|x| print x}\nend",
"def integer_print_10\n\n 10.times {|i| p i}\nend",
"def integer_print_10\n 10.times do |x|\n print x\n end\nend",
"def print\n 9.times do \n puts \"Ruby Basic Exercises\"\n end\nend",
"def repeat(str, int)\n int.times { puts str }\nend",
"... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Parse file Clean balnk or empty lines form a file storing significat lines in given new file returns the number of significant lines | def parse( new_file_name = "#{@full_pathname}.clean.txt" )
lines_total = 0
lines_removed = 0
new_file = File.open( new_file_name, 'w' )
File.open( @full_pathname, 'r' ) do |f|
f.each_line do |curr_line| # Make sure each line has a valid UTF-8 sequence of characters:
... | [
"def parse_file\n line_count = 0\n @text.each_line do |line|\n if line == nil || line == '' || line.size == 0 || line[0] == '#' || line[0] == \"\\n\"\n next\n end\n elements = line.split(' ')\n if elements.size > 2\n puts 'Waring : '.red + 'in file \"' + @file_name.yellow + '... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
GET /widgets GET /widgets.json | def index
@widgets = Widget.all
respond_to do |format|
format.html # index.html.erb
format.json { render json: @widgets }
end
end | [
"def index\n @widgets = @widget_user.widgets\n render json: { widgets: @widgets }\n end",
"def index\n @widgets = request_widgets(visible_widgets_url)\n end",
"def all_visible_widgets\n user_id = params[:id]\n api_link = VISIBLE_WIDGETS_URL + client_id + '&client_secret=' + ... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
DELETE /widgets/1 DELETE /widgets/1.json | def destroy
@widget = Widget.find(params[:id])
@widget.destroy
respond_to do |format|
format.html { redirect_to widgets_url }
format.json { head :no_content }
end
end | [
"def destroy\n @widget.destroy\n respond_to do |format|\n format.html { redirect_to widgets_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @simple_widget.destroy\n respond_to do |format|\n format.html { redirect_to simple_widgets_url, notice: 'Simple widget wa... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Setting up a Mock to simulate the requests. | def setup
@requester = Rack::MockRequest.new(SampleApp)
end | [
"def setup_base_mocks\n RunGitHub.any_instance.expects(:ask).with(\"GitHub Username:\").returns(\"github_username\")\n RunGitHub.any_instance.expects(:ask).with(\"GitHub Password:\").returns(\"github_password\")\n client = mock(\"RestClient::Resource\")\n RestClient::Resource.expects(:new).with(\"http:/... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Admin only; get a sample of students for looking at data across the site | def sample_students_json
raise Exceptions::EducatorNotAuthorized unless current_educator.can_set_districtwide_access?
seed = params.fetch(:seed, '42').to_i
n = params.fetch(:n, '40').to_i
authorized_sample_students = authorized do
Student.active.sample(n, random: Random.new(seed))
end
sam... | [
"def sample_students_json\n seed = params.fetch(:seed, '42').to_i\n n = params.fetch(:n, '40').to_i\n authorized_sample_students = authorized do\n Student.active.sample(n, random: Random.new(seed))\n end\n sample_students_json = authorized_sample_students.as_json({\n only: [:id, :grade, :fi... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
GET /actionables GET /actionables.json | def index
@actionables = Actionable.all
end | [
"def available_actions\n actions = Inventory.where(dataset_id: params[:dataset_id]).order(:object_action).distinct(:object_action).pluck(:object_action)\n respond_to do |format|\n format.json { render json: { success: true, actions: actions } }\n end\n end",
"def actions\n return @actions if @... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
POST /actionables POST /actionables.json | def create
@actionable = Actionable.new(actionable_params)
respond_to do |format|
if @actionable.save
format.html { redirect_to @actionable, notice: 'Actionable was successfully created.' }
format.json { render :show, status: :created, location: @actionable }
else
format.htm... | [
"def index\n @actionables = Actionable.all\n end",
"def create_actionable\n actionable_node = Neography::Node.create(\"object_id\" => self.id, \"object_type\" => self.class.to_s)\n actionable_node.add_to_index(\"actionables_nodes_index\", \"class0id\", \"#{self.class.to_s}0#{self.id}\")\n e... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
PATCH/PUT /actionables/1 PATCH/PUT /actionables/1.json | def update
respond_to do |format|
if @actionable.update(actionable_params)
format.html { redirect_to @actionable, notice: 'Actionable was successfully updated.' }
format.json { render :show, status: :ok, location: @actionable }
else
format.html { render :edit }
format.jso... | [
"def update\n head :forbidden\n\n #@action = Action.find(params[:id])\n\n #if @action.update_attributes(params[:action])\n # head :no_content\n # else\n # render json: @action.errors, status: :unprocessable_entity\n # end\n end",
"def update\n @action_set = ActionSet.find(params[:id])\... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
DELETE /actionables/1 DELETE /actionables/1.json | def destroy
@actionable.destroy
respond_to do |format|
format.html { redirect_to actionables_url, notice: 'Actionable was successfully destroyed.' }
format.json { head :no_content }
end
end | [
"def destroy\n @single_action.destroy\n respond_to do |format|\n format.json { head :no_content }\n end\n end",
"def destroy\n @ai_action.destroy\n respond_to do |format|\n format.html { redirect_to admin_ai_actions_url }\n format.json { head :no_content }\n end\n en... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
method showing lives remaining | def show_lives
puts "Lives remaining: #{@players[0].name}: #{@players[0].life}/3 - #{@players[1].name}: #{@players[1].life}/3"
end | [
"def show_lives(lives)\n puts \"#{lives} Lives left\"\n end",
"def take_life\n @lives -= 1\n end",
"def reduce_life\n if @lives > 0\n @lives -= 1\n end\n end",
"def remove_life\r\n @lives -= 1\r\n end",
"def life_count\n puts \"#{@player1.name}'s lives: #{@player1.lives}\\n#{@play... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Parse the uploaded file. Resulting data will be in data | def parse(uploaded_file)
parser_class =
case uploaded_file.content_type
when "application/vnd.ms-excel"
ExcelParser
when "text/csv", "application/octet-stream", "text/plain"
CSVParser
else
self.errors << "Do not know how to parse #{uploaded_file.origi... | [
"def uploaded_data=(file)\n self.data = []\n if !file.kind_of?(String)\n self.name = file.original_filename\n self.content_type = file.content_type.chomp\n self.data = file.read\n end\n end",
"def parse_data\n end",
"def parse\n uploader = FileUpload.new(params[:contacts])\n up... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Returns array of keys that do not have value in the hash Given +required_keys+ should be an array of +string+ | def missing_keys_from(required_keys)
required_keys.select{ |k| self.get(k).to_s.empty? }
end | [
"def reject_keys!(hash, keys)\n hash.reject { |k, _| keys.include?(k) }\n end",
"def only(hash, *keys)\n s_keys = keys.flatten.collect{|k| k.to_s}\n hash.delete_if{ |k,v| !keys.flatten.include?(k) && !s_keys.include?(k) }\n hash\n end",
"def extra_keys( keys )\n incoming = keys\n ... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Make Update expression 'SET = :' : points to a value from the expression_attribute_value | def make_update_expression_values(event,attr_values)
update_string = 'SET '
event.each do |k,v|
update_string += "#{make_expression_key(k,"names")} = #{attr_values[k].key(v)}, "
end
return update_string[0...-2]
end | [
"def update_value(expr, expr_single)\n query = \"update replace \" + expr + \" with \" + expr_single\n execute_query(query)\n rescue => e\n raise e \n end",
"def set(column, value)\n @set_clauses << [column, Translate.escape_sql(value)].join(' = ')\n end",
"def expression=(value)\n ... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
create a new archive by merging this and another archive | def merge(other)
assert_archive other
data = deep_clone(@data)
merge_data data, other.as_json, other.uri
self.class.new data
end | [
"def merge!(other)\n assert_archive other\n clear_caches\n\n merge_data @data, other.as_json, other.uri\n nil\n end",
"def make_archive(archivename, archive_comment, sdrf)\n project_dir = ExpandController.path_to_project_dir(command_object.project)\n extracted_dir = File.join(project_... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
destructively merge this with the given archive | def merge!(other)
assert_archive other
clear_caches
merge_data @data, other.as_json, other.uri
nil
end | [
"def merge(other)\n assert_archive other\n\n data = deep_clone(@data)\n merge_data data, other.as_json, other.uri\n\n self.class.new data\n end",
"def restore_archive\n end",
"def archive!\n archive\n save!(validate: false)\n end",
"def merge(other, sibling_com... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Gets the countdownDisplayBeforeRestartInMinutes property value. The number of minutes before the restart time to display the countdown dialog for pending restarts. | def countdown_display_before_restart_in_minutes
return @countdown_display_before_restart_in_minutes
end | [
"def countdown_display_before_restart_in_minutes=(value)\n @countdown_display_before_restart_in_minutes = value\n end",
"def reminder_minutes_before_start\n return @reminder_minutes_before_start\n end",
"def reminder_minutes_before_start=(value)\n ... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Sets the countdownDisplayBeforeRestartInMinutes property value. The number of minutes before the restart time to display the countdown dialog for pending restarts. | def countdown_display_before_restart_in_minutes=(value)
@countdown_display_before_restart_in_minutes = value
end | [
"def countdown_display_before_restart_in_minutes\n return @countdown_display_before_restart_in_minutes\n end",
"def reminder_minutes_before_start=(value)\n @reminder_minutes_before_start = value\n end",
"def schedule_imminent_restart_warning_in_minutes=(value)... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Gets the gracePeriodInMinutes property value. The number of minutes to wait before restarting the device after an app installation. | def grace_period_in_minutes
return @grace_period_in_minutes
end | [
"def grace_period_in_minutes=(value)\n @grace_period_in_minutes = value\n end",
"def grace_period\n @grace_period\n end",
"def grace_period_hours\n return @grace_period_hours\n end",
"def health_check_grace_period\n data[:health_check_grace_peri... | {
"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.