query
stringlengths
7
9.5k
document
stringlengths
10
1.07M
negatives
listlengths
19
19
metadata
dict
lexer rule space! (SPACE) (in CSV.g)
def space! # -> uncomment the next line to manually enable rule tracing # trace_in( __method__, 3 ) type = SPACE channel = ANTLR3::DEFAULT_CHANNEL # - - - - main rule block - - - - # at line 12:9: ( ' ' )+ # at file 12:9: ( ' ' )+ match_count_2 = 0 ...
[ "def space!\n # -> uncomment the next line to manually enable rule tracing\n # trace_in( __method__, 8 )\n\n \n # - - - - main rule block - - - -\n # at line 88:5: ( ' ' | '\\\\t' )+\n # at file 88:5: ( ' ' | '\\\\t' )+\n match_count_12 = 0\n while true\n alt_12 = 2\n ...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
Returns an array of locations for a circle.
def get_circle(location, r) startY = location.y - r startX = 0 endX = 0 if startY % 2 == 0 startX = location.x - (r / 2.0).floor endX = location.x + r; else startX = location.x - (r / 2.0).floor endX = location.x + r; if r % 2 == 0 startX+=1; endX+=1; end end e...
[ "def getPointOnCircle(cx,cy,r,angle)\n x = cx + (r*Math.cos(Math::PI*angle/180)).round\n y = cy + (r*Math.sin(Math::PI*angle/180)).round \n\n return [x,y]\nend", "def location(x, y, theta, distance)\n \t return [\n \t x + distance * Math.cos(theta),\n \t y - distance * Math.sin(theta)\n \t ]\n \t...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
List all available style names
def style_names styles.keys end
[ "def styles\n mentos(:get_all_styles)\n end", "def character_style_names\n ::Kramdown::Parser::IdmlStory::HANDLED_CHARACTER_STYLES.map { |e|\n e.gsub('CharacterStyle/', '')\n }\n end", "def paragraph_style_names\n ::Kramdown::Parser::IdmlStory.paragraph_style_mappings....
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
Remove notifications from problem editors
def remove_problem_upvote_notifications ((@resource.versions.map{ |version| version.user }).uniq - [@actor]).each do |editor| n = Notification.find_by(recipient: editor, actor: @actor, notifiable: @resource, ...
[ "def removeNotifications\r\n @notifications.clear\r\n end", "def reset_errors_notification\n @notifications.delete(:error)\n end", "def removeCustomNotification sender\n return if notifications_table.selectedRow == -1\n removed = custom_notification_list[notifications_table.selectedRow]\n ...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
Remove notifications from proof editors
def remove_proof_upvote_notifications ((@resource.versions.map{ |version| version.user }).uniq - [@actor]).each do |editor| n = Notification.find_by(recipient: @resource.user, actor: @actor, action_type: "like", notifiable: @resource) if @resource.user != @act...
[ "def removeNotifications\r\n @notifications.clear\r\n end", "def remove_problem_upvote_notifications\n ((@resource.versions.map{ |version| version.user }).uniq - [@actor]).each do |editor|\n n = Notification.find_by(recipient: editor,\n actor: @actor,\...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
Remove notification from owner of comment
def remove_comment_upvote_notifications n = Notification.find_by(recipient: @resource.user, actor: @actor, action_type: "like", notifiable: @resource) if @resource.user != @actor if !n.nil? n.destroy @removed += 1 end ...
[ "def remove_from_notification (n)\n logger.debug2 \"comment id #{id}. Notification id #{n.id}. notification key #{n.noti_key}\" if debug_notifications\n # only modify unread notifications\n return unless n.noti_read == 'N'\n cn = notifications.where(\"notification_id = ?\", n.id).first\n logger.debu...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
'anchor' is one of the ANCHOR_ constants above. 'where' is the pixel location to slide around, and slide_direction is +/1 to indicate which way to slide when showing. 'displacement' is where along the nonanchored axis the box should be.
def initialize(anchor, where, slide_direction, disp = 0) super() @rl = Opal::ResourceLocator.instance @bgcolor = Rubygame::Color[:blue] @border = Rubygame::Color[:white] @anchor = anchor @where = where @slide_direction = slide_direction @displacement = disp @slide_offset = 0 @spe...
[ "def setup_slide\n return TSBS.error(@acts[0], 4, @used_sequence) if @acts.size < 5\n @move_obj.clear_move_info\n xpos = (flip ? -@acts[1] : @acts[1])\n ypos = @acts[2]\n slide(xpos, ypos, @acts[3], @acts[4])\n end", "def anchor=(value)\n @anchor = value\n end", "def se...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
Adjusts the scale (and inverse_scale) by the given amount ZOOM_SPEED
def zoom(delay) self.scale += delay * ZOOM_SPEED end
[ "def update_zoom\n if self.zoom_x < 2\n self.zoom_x += 0.05\n self.zoom_y += 0.05\n end\n end", "def update_zoom\n @effectus_old_zoom_x = @picture.zoom_x\n @effectus_old_zoom_y = @picture.zoom_y\n self.zoom_x = @effectus_old_zoom_x / 100.0\n self.zoom_y = @effectus_old_zoom_y / 100.0\...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
Register a lock to be renewed every extend_interval seconds.
def register(lock, extend_interval) registration = Registration.new registration.lock = lock registration.mutex = Mutex.new registration.thread = Thread.current registration.acquired_at = Time.now registration.extend_interval = extend_interval registration.released = false ...
[ "def extend_lock_if_expires_in_less_than(duration)\n extend_lock if duration > remaining_lock_time\n end", "def lock_duration=(interval)\n @lock_duration = Core::Utils::Interval.try_convert(interval)\n end", "def renew!(holder:)\n if held_by?(holder)\n touch\n\n ...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
Extend all currently registered locks that have been held longer than the extend_interval since they were last acquired/extended. If any locks have expired (should not happen), it will release them.
def extend_locks # Make a local copy of the locks array to avoid accessing it outside of the mutex. locks_copy = @locks_mutex.synchronize { locks.dup } locks_copy.each { |registration| extend_lock(registration) } @locks_mutex.synchronize do locks.delete_if(&:released) end end
[ "def extend_lock_if_expires_in_less_than(duration)\n extend_lock if duration > remaining_lock_time\n end", "def register(lock, extend_interval)\n registration = Registration.new\n registration.lock = lock\n registration.mutex = Mutex.new\n registration.thread = Thread.curre...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
GET /selecaos/1 GET /selecaos/1.json
def show @selecao = Selecao.find(params[:id]) respond_to do |format| format.html # show.html.erb format.json { render json: @selecao } end end
[ "def show\n @seguro = Seguro.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @seguro }\n end\n end", "def show\n @secao = Secao.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { ren...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
GET /selecaos/new GET /selecaos/new.json
def new @selecao = Selecao.new respond_to do |format| format.html # new.html.erb format.json { render json: @selecao } end end
[ "def new\n @newse = Newse.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @newse }\n end\n end", "def new\n @seguro = Seguro.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @seguro }\n end\n e...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
POST /selecaos POST /selecaos.json
def create @selecao = Selecao.new(params[:selecao]) respond_to do |format| if @selecao.save format.html { redirect_to @selecao, notice: 'Selecao was successfully created.' } format.json { render json: @selecao, status: :created, location: @selecao } else format.html { render...
[ "def create\n @seito = Seito.new(seito_params)\n\n respond_to do |format|\n if @seito.save\n format.html { redirect_to @seito, notice: \"生徒を追加しました\" }\n format.json { render :show, status: :created, location: @seito }\n else\n format.html { render :new }\n format.json { r...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
PUT /selecaos/1 PUT /selecaos/1.json
def update @selecao = Selecao.find(params[:id]) respond_to do |format| if @selecao.update_attributes(params[:selecao]) format.html { redirect_to @selecao, notice: 'Selecao was successfully updated.' } format.json { head :no_content } else format.html { render action: "edit" ...
[ "def update\n\n excursao = Excursao.find params[:id]\n \n if excursao.save excursaos_params\n render status: :no_content, json: {}\n else\n render status: :bad_request, json: excursao.errors.messages\n end\n end", "def update\n @seguro = Seguro.find(params[:id])\n\n respond_to do |...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
DELETE /selecaos/1 DELETE /selecaos/1.json
def destroy @selecao = Selecao.find(params[:id]) @selecao.destroy respond_to do |format| format.html { redirect_to selecaos_url } format.json { head :no_content } end end
[ "def destroy\n @seguro = Seguro.find(params[:id])\n @seguro.destroy\n\n respond_to do |format|\n format.html { redirect_to seguros_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @seguidore = Seguidore.find(params[:id])\n @seguidore.destroy\n\n respond_to do |...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
GET /franchises GET /franchises.json
def index @franchises = Franchise.all end
[ "def show \n @franchise = @franchise_set.franchises.find(params[:id])\n\n respond_with(@franchise_set, @franchise)\n end", "def show\n @devenir_franchise = DevenirFranchise.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @devenir_fra...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
Converts the given field to the value that the database adapter returns as a usable column name: column_alias_for("users.id") => "users_id" column_alias_for("sum(id)") => "sum_id" column_alias_for("count(distinct users.id)") => "count_distinct_users_id" column_alias_for("count()") => "count_all"
def column_alias_for(field) column_alias = +field column_alias.gsub!(/\*/, "all") column_alias.gsub!(/\W+/, " ") column_alias.strip! column_alias.gsub!(/ +/, "_") @connection.table_alias_for(column_alias) end
[ "def column_alias_for(field); end", "def column_alias(column)\r\n end", "def translate_column(col, mapping)\n if mapping[col][:name]\n mapping[col][:name]\n else\n if col[-3,3] == \"_id\"\n col = col[0, col.length - 3]\n end\n col.humanize\n ...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
Same as count but perform the query asynchronously and returns an ActiveRecord::Promise
def async_count(column_name = nil) async.count(column_name) end
[ "def async_count_by_sql(sql)\n connection.select_value(sanitize_sql(sql), \"#{name} Count\", async: true).then(&:to_i)\n end", "def count\n\n #if lib.respond_to?(:qry_count)\n run.free unless @has_run\n lib.qry_count(@query)\n #else\n # @last_resultset ? @last_resultset.size : 0\...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
Calculates the average value on a given column. Returns +nil+ if there's no row. See calculate for examples with options. Person.average(:age) => 35.8
def average(column_name) calculate(:average, column_name) end
[ "def average(column)\n run.avg(column)\n end", "def average(column)\n if s = sum(column)\n s / _all_with_present_column(column).count.to_f\n end\n end", "def avg(column)\n get(:avg[column])\n end", "def avg_col(k)\n map{|e|e[k]}.find_a...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
Same as average but perform the query asynchronously and returns an ActiveRecord::Promise
def async_average(column_name) async.average(column_name) end
[ "def average_student_gpa\n \"SELECT AVG(gpa) from students;\"\nend", "def loadavg\n do_request 'loadavg'\n end", "def instructor_avg_wait_time(ord1, ord2 = nil)\n city_id = 2\n date1 = Day.find_by(cycle: Cycle.current(2), ord: ord1).date\n date2 = ord2 ? Day.find_by(cycle: Cycle.current(2), ord...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
Calculates the minimum value on a given column. The value is returned with the same data type of the column, or +nil+ if there's no row. See calculate for examples with options. Person.minimum(:age) => 7
def minimum(column_name) calculate(:minimum, column_name) end
[ "def minimum(column_name, options = {})\n calculate(:minimum, column_name, options)\n end", "def min(column)\n get(:min[column])\n end", "def min(column_name)\n calculate(:min, column_name)\n end", "def min(column)\n _all_with_present_column(column).min\n end", "d...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
Same as minimum but perform the query asynchronously and returns an ActiveRecord::Promise
def async_minimum(column_name) async.minimum(column_name) end
[ "def oldest_ready_object\n ActiveRecord::Base.connection.execute(\"select * from media_objects where created = (select min(created) from media_objects where status = 'received') limit 1;\").first\n end", "def async_find_by_sql(sql, binds = [], preparable: nil, &block)\n _query_by_sql(sql, binds, preparab...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
Calculates the maximum value on a given column. The value is returned with the same data type of the column, or +nil+ if there's no row. See calculate for examples with options. Person.maximum(:age) => 93
def maximum(column_name) calculate(:maximum, column_name) end
[ "def max(column)\n get(:max[column])\n end", "def max(attr)\n column(attr).max\n end", "def max(column)\n _all_with_present_column(column).max\n end", "def max(column)\n run.max(column)\n end", "def column_max( table, column )\n\tmax = -9999999\n\t(0...(co...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
Same as maximum but perform the query asynchronously and returns an ActiveRecord::Promise
def async_maximum(column_name) async.maximum(column_name) end
[ "def latest_result\n return get_entities(Result, data.id, :limit => 1).first\n end", "def query_max_task_id\n check_max_id(@db_base.query_max_task_id.next)\n end", "def async_minimum(column_name)\n async.minimum(column_name)\n end", "def latest_job\n @mysql.query(\"select * from...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
Same as sum but perform the query asynchronously and returns an ActiveRecord::Promise
def async_sum(identity_or_column = nil) async.sum(identity_or_column) end
[ "def record_sum(session, database)\n session.send(database).select_one( \\\n \"select sum(number1) + sum(number2) + sum(number3) + sum(number4) as sum\n from big_rep\")['sum'].to_f\n end", "def async_count_by_sql(sql)\n connection.select_value(sanitize_sql(sql), \"#{name} Count\", async: t...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
This calculates aggregate values in the given column. Methods for count, sum, average, minimum, and maximum have been added as shortcuts. Person.calculate(:count, :all) The same as Person.count Person.average(:age) SELECT AVG(age) FROM people... Selects the minimum age for any family without any minors Person.group(:la...
def calculate(operation, column_name) operation = operation.to_s.downcase if @none case operation when "count", "sum" result = group_values.any? ? Hash.new : 0 return @async ? Promise::Complete.new(result) : result when "average", "minimum", "maximum" r...
[ "def calculate(scope, method, column)\n case method\n when :count\n calculation = \"COUNT(#{column || \"*\"})\"\n when :maximum\n calculation = \"MAX(#{column})\"\n when :minimum\n calculation = \"MIN(#{column})\"\n when :sum\n calculation = \"S...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
Use pluck as a shortcut to select one or more attributes without loading an entire record object per row. Person.pluck(:name) instead of Person.all.map(&:name) Pluck returns an Array of attribute values typecasted to match the plucked column names, if they can be deduced. Plucking an SQL fragment returns String values ...
def pluck(*column_names) return [] if @none if loaded? && all_attributes?(column_names) result = records.pluck(*column_names) if @async return Promise::Complete.new(result) else return result end end if has_include?(column_names.first) ...
[ "def pluck(*column_names)\n column_names.map! do |column_name|\n if column_name.is_a?(Symbol) && attribute_alias?(column_name)\n attribute_alias(column_name)\n else\n column_name.to_s\n end\n end\n\n if has_include?(column_names.first)\n construct_relatio...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
Same as pluck but perform the query asynchronously and returns an ActiveRecord::Promise
def async_pluck(*column_names) async.pluck(*column_names) end
[ "def pluck(*column_names)\n return [] if @none\n\n if loaded? && all_attributes?(column_names)\n result = records.pluck(*column_names)\n if @async\n return Promise::Complete.new(result)\n else\n return result\n end\n end\n\n if has_include?(column_na...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
Pick the value(s) from the named column(s) in the current relation. This is shorthand for relation.limit(1).pluck(column_names).first, and is primarily useful when you have a relation that's already narrowed down to a single row. Just like pluck, pick will only load the actual value, not the entire record object, so it...
def pick(*column_names) if loaded? && all_attributes?(column_names) result = records.pick(*column_names) return @async ? Promise::Complete.new(result) : result end limit(1).pluck(*column_names).then(&:first) end
[ "def pick(*fields)\n limit(1).pluck(*fields).first\n end", "def pluck(*column_names)\n return [] if @none\n\n if loaded? && all_attributes?(column_names)\n result = records.pluck(*column_names)\n if @async\n return Promise::Complete.new(result)\n else\n ...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
Same as pick but perform the query asynchronously and returns an ActiveRecord::Promise
def async_pick(*column_names) async.pick(*column_names) end
[ "def pick(*column_names)\n if loaded? && all_attributes?(column_names)\n result = records.pick(*column_names)\n return @async ? Promise::Complete.new(result) : result\n end\n\n limit(1).pluck(*column_names).then(&:first)\n end", "def async_find_by_sql(sql, binds = [], preparable: n...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
GET /qx/take_offs GET /qx/take_offs.json
def index # @qx_take_offs = Qx::TakeOff.all per_page = params[:per_page] || 100 @q = Qx::TakeOff.ransack(params[:q]) @qx_take_offs = @q.result().paginate(:page => params[:page], :per_page => per_page) end
[ "def get_client_throughput_time_series_data(args = {}) \n get(\"/clients.json/stats/throughput\", args)\nend", "def get_trouble_spots()\n exec_get(\"#{@base_path}/api/v2/customers/trouble_spots.json?api_key=#{@api_key}\")\n end", "def update\n respond_to do |format|\n if @qx_take_off.update(qx_take_...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
POST /qx/take_offs POST /qx/take_offs.json
def create runway = qx_take_off_params[:runway].split("/") runway.each do |item| qx_take_off_params[:runway_id] = Qx::Runway.get_runay_id(qx_take_off_params[:airport_id], item) @qx_take_off = Qx::TakeOff.new(qx_take_off_params) end p runway respond_to do |format| if @qx_take_off...
[ "def create\n @takeoff = Takeoff.new(params[:takeoff])\n\n respond_to do |format|\n if @takeoff.save\n format.html { redirect_to @takeoff, notice: 'Takeoff was successfully created.' }\n format.json { render json: @takeoff, status: :created, location: @takeoff }\n else\n format....
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
PATCH/PUT /qx/take_offs/1 PATCH/PUT /qx/take_offs/1.json
def update respond_to do |format| if @qx_take_off.update(qx_take_off_params) format.html { redirect_to @qx_take_off, notice: 'Take off was successfully updated.' } format.json { render :show, status: :ok, location: @qx_take_off } else format.html { render :edit } format.j...
[ "def update\n @takeoff = Takeoff.find(params[:id])\n\n respond_to do |format|\n if @takeoff.update_attributes(params[:takeoff])\n format.html { redirect_to @takeoff, notice: 'Takeoff was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render ac...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
DELETE /qx/take_offs/1 DELETE /qx/take_offs/1.json
def destroy @qx_take_off.destroy respond_to do |format| format.html { redirect_to qx_take_offs_url, notice: 'Take off was successfully destroyed.' } format.json { head :no_content } end end
[ "def destroy\n @takeoff = Takeoff.find(params[:id])\n @takeoff.destroy\n\n respond_to do |format|\n format.html { redirect_to takeoffs_url }\n format.json { head :no_content }\n end\n end", "def cmd_delete argv\n setup argv\n uuid = @hash['uuid']\n response = @api.delete(uuid)\n...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
GET /host_states GET /host_states.json
def index @host_states = HostState.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 device_states_list\n get \"deviceStates\"\n end", "def index\n @api_states = Api::State.all\n end", "def host_states=...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
POST /host_states POST /host_states.json
def create @host_state = HostState.new(host_state_params) respond_to do |format| if @host_state.save format.html { redirect_to @host_state, notice: 'Host state was successfully created.' } format.json { render :show, status: :created, location: @host_state } else format.html...
[ "def host_states=(value)\n @host_states = value\n end", "def index\n @host_states = HostState.all\n end", "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 suc...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
PATCH/PUT /host_states/1 PATCH/PUT /host_states/1.json
def update respond_to do |format| if @host_state.update(host_state_params) format.html { redirect_to @host_state, notice: 'Host state was successfully updated.' } format.json { render :show, status: :ok, location: @host_state } else format.html { render :edit } format.jso...
[ "def update\n @api_state = Api::State.find(params[:id])\n\n if @api_state.update(api_state_params)\n head :no_content\n else\n render json: @api_state.errors, status: :unprocessable_entity\n end\n end", "def update\n respond_to do |format|\n if @server_state.update(server_state_para...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
DELETE /host_states/1 DELETE /host_states/1.json
def destroy @host_state.destroy respond_to do |format| format.html { redirect_to host_states_url, notice: 'Host state was successfully destroyed.' } format.json { head :no_content } end end
[ "def delete(state)\n @db[:states].filter(host: state.host, service: state.service).delete\n end", "def destroy\n @ot_state = OtState.find(params[:id])\n @ot_state.destroy\n\n respond_to do |format|\n format.html { redirect_to ot_states_url }\n format.json { head :ok }\n end\n end", ...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
GET /warehouse_lists GET /warehouse_lists.xml
def index @warehouse_lists = get_warehouse_lists(:page => params[:page]) respond_to do |format| format.html # index.html.erb format.xml { render :xml => @warehouse_lists } end end
[ "def show\n @warehouse_list = WarehouseList.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.xml { render :xml => @warehouse_list }\n end\n end", "def index\n @list = List.find(params[:list_id])\n @list_items = @list.list_items.find(:all)\n\n respon...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
GET /warehouse_lists/1 GET /warehouse_lists/1.xml
def show @warehouse_list = WarehouseList.find(params[:id]) respond_to do |format| format.html # show.html.erb format.xml { render :xml => @warehouse_list } end end
[ "def index\n @warehouse_lists = get_warehouse_lists(:page => params[:page])\n\n respond_to do |format|\n format.html # index.html.erb\n format.xml { render :xml => @warehouse_lists }\n end\n end", "def index\n @list = List.find(params[:list_id])\n @list_items = @list.list_items.find(:al...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
Iterates until reaches coordinate
def each_until(coordinate) raise UnexpectedUntilCoordinate if coordinate < self (y_param..coordinate.y).each do |j| (x_param..coordinate.x).each do |i| yield(Coordinate.new(i, j)) end end end
[ "def loop\n measurement = yield @position\n\n while true do\n position = control measurement\n\n measurement = yield position\n end\n end", "def gather_until_none(walker, coords, inventory_window)\n total_count = 0\n loop do\n # Gather as many as we find, going from one silt pile to...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
def user_project_participation(project_id) self.participants.where(project_id: project_id).first end
def current_project_participant(project_id) # if self.has_accepted?(project_id) Participant.where(project_id: project_id, user_id: self.id).first # end end
[ "def participation(project)\n \tparticipations.find_by(project: project)\n end", "def project_membership_for(project)\n ProjectMembership.where(:user_id => self.id , :project_id => project.id ).first\n end", "def contribution(project)\n \tcontributions.find_by(participation: participation(project))\n en...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
POST /electronic_prescriptions POST /electronic_prescriptions.json
def create electronic_prescription_params[:status] = electronic_prescription_params[:status].to_i @electronic_prescription = ElectronicPrescription.new(electronic_prescription_params) respond_to do |format| if @electronic_prescription.save format.html { redirect_to @electronic_prescription, ...
[ "def create\n\t\tnew_prescription = current_user.prescriptions.create!(rx_params)\n\t\trender json: new_prescription\n\tend", "def create\n @prescription = @user.prescriptions.build(params[:prescription])\n\n respond_to do |format|\n if @prescription.save\n format.json { render json: @prescripti...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
PATCH/PUT /electronic_prescriptions/1 PATCH/PUT /electronic_prescriptions/1.json
def update electronic_prescription_params[:status] = electronic_prescription_params[:status].to_i respond_to do |format| if @electronic_prescription.update(electronic_prescription_params) format.html { redirect_to @electronic_prescription, notice: 'Electronic prescription was successfully update...
[ "def update\n @prescription = Prescription.find(params[:id])\n\n respond_to do |format|\n if @prescription.update_attributes(params[:prescription])\n format.json { head :no_content }\n else\n format.json { render json: @prescription.errors, status: :unprocessable_entity }\n end\n ...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
DELETE /electronic_prescriptions/1 DELETE /electronic_prescriptions/1.json
def destroy @electronic_prescription.destroy respond_to do |format| format.html { redirect_to electronic_prescriptions_url, notice: 'Electronic prescription was successfully destroyed.' } format.json { head :no_content } end end
[ "def destroy\n @prescription = Prescription.find(params[:id])\n @prescription.destroy\n\n respond_to do |format|\n format.json { head :no_content }\n end\n end", "def destroy\n @prescription.destroy\n respond_to do |format|\n format.html { redirect_to prescriptions_url }\n format...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
Greet displays a greeting.
def greet puts '------------------------' puts "Greetings to you #{@name}" end
[ "def greeting (name)\n\tputs \"Hello \" + name\t\nend", "def say_greeting\r\n greeting = \"\\t\\t Welcome to the Virtual Crazy 8-Ball game!\" +\r\n \"\\n\\n\\n\\n\\n\\n\\t To play: \" +\r\n \"\\n\\t Simply ask any question you desire to have answered and press ENTER.\" +\r\n \"\\n\\t The 8-Ball will ...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
Joke displays a joke.
def joke puts "#{@name} here is a joke for you:" puts '' puts "Teacher: Anyone who thinks he's stupid may stand up!" puts '' puts 'Nobody stands up' puts '' puts 'Teacher: Im sure there are some stupid students over here!!' puts '' puts 'Little Johnny stands up' puts '' puts ...
[ "def show\n\t\t@joke = Joke.find(params[:id])\n\tend", "def show\n @joke = Joke.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render :json => @joke }\n end\n end", "def joke; end", "def joke\n sample(jokes)\n end", "def print_m...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
GET /splits GET /splits.json
def index @splits = Split.all end
[ "def split_trade\n @trade = Trade.find params[:id]\n @trade.split_trade(params[:splits].values)\n respond_to do |format|\n format.json { render json: {success: @trade.errors.blank?,message: @trade.errors.full_messages} }\n end\n end", "def index\n @item_splits = ItemSplit.all\n end", "def ...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
POST /splits POST /splits.json
def create @split = Split.new(split_params) respond_to do |format| if @split.save format.html { redirect_to @split, notice: 'Split was successfully created.' } format.json { render :show, status: :created, location: @split } else format.html { render :new } format.js...
[ "def create\n @test_split = TestSplit.new(test_split_params)\n\n respond_to do |format|\n if @test_split.save\n format.html { redirect_to @test_split, notice: 'Test split was successfully created.' }\n format.json { render :show, status: :created, location: @test_split }\n else\n ...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
PATCH/PUT /splits/1 PATCH/PUT /splits/1.json
def update respond_to do |format| if @split.update(split_params) format.html { redirect_to @split, notice: 'Split was successfully updated.' } format.json { render :show, status: :ok, location: @split } else format.html { render :edit } format.json { render json: @split.e...
[ "def update\n respond_to do |format|\n if @split.update(split_params)\n format.html { redirect_to @split, notice: 'Split was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: 'edit' }\n format.json { render json: @split.errors,...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
DELETE /splits/1 DELETE /splits/1.json
def destroy @split.destroy respond_to do |format| format.html { redirect_to splits_url, notice: 'Split was successfully destroyed.' } format.json { head :no_content } end end
[ "def destroy\n @split = Split.find(params[:id])\n @split.destroy\n\n respond_to do |format|\n format.html { redirect_to(splits_url) }\n format.xml { head :ok }\n end\n end", "def destroy\n @split.destroy\n respond_to do |format|\n format.html { redirect_to splits_url }\n fo...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
Fetch recordings from their sources to local paths
def fetch @recordings.map do |uri, path| STDERR.puts("# Fetching #{uri} to #{path}") fetch = Mixlib::ShellOut.new( "curl --continue-at - --output #{path} #{uri}", live_stream: STDERR ) fetch.run_command { path: path, result: fetch.exi...
[ "def fetch\n clean_load_dir\n pull_from_remote_buckets(@remote_buckets)\n pull_from_local_dirs(@local_dirs)\n load_dir_json_files\n end", "def fetch_files_from host\n\t\tfetcher = host[:fetcher]\n\t\tswitches = host[:switches]\n\t\tbase_path = host[:base_path]\n\t\tlist_files = {}\n\t\tfetcher.connec...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
Load configuration from `path`. It should be a YAMLformatted file with this content: `base_uri`: the base URI common to all recordings `base_path`: the base local path common to all recordings `file_pattern`: a pattern to construct each file's name, in `format`'s format. The format may vary yeartoyear. `recordings`: a ...
def load_config(path) # Read and parse the YAML configuration file config = YAML.safe_load(File.read(path)) recordings = [] # Build a hash whose keys are URIs and values are local file paths # Iterate over the list of each speaker's recordings config['recordings'].map do |speaker, ...
[ "def configure_from_yaml(path, opts = {})\n begin\n yml = YAML.load(File.read(path))\n yml = yml[opts[:hash]] unless opts[:hash].nil?\n configure_from_hash(yml)\n rescue Errno::ENOENT => e\n puts e.message\n end\n end", "def load path\n file = File.open(path, 'r'...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
PATCH/PUT /school_cycle_has_subjects/1 PATCH/PUT /school_cycle_has_subjects/1.json
def update respond_to do |format| if @school_cycle_has_subject.update(school_cycle_has_subject_params) format.html { redirect_to ["asig",@school_cycle_has_subject], notice: 'School cycle has subject was successfully updated.' } format.json { render :show, status: :ok, location: @school_cycle_h...
[ "def update\n respond_to do |format|\n if @cycle_has_subject.update(cycle_has_subject_params)\n format.html { redirect_to @cycle_has_subject, notice: 'Cycle has subject was successfully updated.' }\n format.json { render :show, status: :ok, location: @cycle_has_subject }\n else\n f...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
DELETE /school_cycle_has_subjects/1 DELETE /school_cycle_has_subjects/1.json
def destroy @school_cycle_has_subject.destroy respond_to do |format| format.html { redirect_to asig_school_cycle_has_subjects_path, notice: 'School cycle has subject was successfully destroyed.' } format.json { head :no_content } end end
[ "def destroy\n @cycle_has_subject.destroy\n respond_to do |format|\n format.html { redirect_to cycle_has_subjects_url, notice: 'Cycle has subject was successfully destroyed.' }\n format.json { head :no_content }\n end\n end", "def destroy\n @manual_subject = Manual::Subject.find(params[:id]...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
Instance methods transform categories hash into nested objects for view simplicity
def categories raw_categories.to_hashugar end
[ "def categories\n Hash[self.class.catalogs.map { |fld, klass|\n name = fld.gsub(/_id$/, '_name');\n [fld, {:id => self.send(fld), :name => self.send(name)}] rescue nil\n }.reject {|cat| cat.nil?}]\n end", "def extract_categories cats\n cats.inject Hash.new do |hash, tag|\n\...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
POST /ads POST /ads.json
def create @ad = Ad.new(ad_params) respond_to do |format| if @ad.save format.html { redirect_to @ad, notice: 'Ad was successfully created.' } format.json { render :show, status: :created, location: @ad } else format.html { render :new } format.json { render json: @ad...
[ "def create\n @ad = Ad.new(ad_params)\n\n if @ad.save\n render json: @ad, status: :created, location: @ad\n else\n render json: @ad.errors, status: :unprocessable_entity\n end\n end", "def create\n @ad = Ad.new(params[:ad])\n\n if @ad.save\n render json: @ad, status: :created, lo...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
Todo: Anyone can write or view the list of reviews for a movie, but only an admin or the user who created a review should be allowed to edit or delete it Implement this by removing the edit and delete buttons on the reviewshow page except for Admins, and create a link on the user profile page to My Reviews. Create a ne...
def index @reviews = @movie.reviews end
[ "def edit\n @movie = Movie.find(params[:movie_id])\n \n @review = @movie.reviews.find(params[:id])\n end", "def show\n @movie = Movie.find(params[:id])\n @reviews = @movie.reviews.order('updated_at DESC')\n end", "def show\n @movie = Movie.find(params[:movie_id])\n \n #find a review in...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
POST /numbers POST /numbers.json
def create @number = Number.new(params[:number]) respond_to do |format| if @number.save format.json { render json: @number, status: :created } else format.json { render json: @number.errors, status: :unprocessable_entity } end end end
[ "def create\n Rails.logger.info ['API: number assignment requested', {request: request_loginfo}]\n\n affiliate_user_to_project_if_yet\n\n @number = build_new_number\n if @number.save\n marking_if_mark_requested number_params[:mark]\n render json: @number\n else\n render json: { message...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
DELETE /numbers/1 DELETE /numbers/1.json
def destroy @number = Number.where(:value => params[:number][:value]).first @number.destroy respond_to do |format| format.json { head :no_content } end end
[ "def destroy\n @num.destroy\n respond_to do |format|\n format.html { redirect_to nums_url, notice: \"Num was successfully destroyed.\" }\n format.json { head :no_content }\n end\n end", "def destroy\n @static_number.destroy\n respond_to do |format|\n format.html { redirect_to static...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
GET /contentperpages GET /contentperpages.json
def index @contentperpages = Contentperpage.all end
[ "def pages\n self.list(:pages)\n end", "def pages\n get(\"v1/account/#{@email}/pages\")\n end", "def index\n @pages = Page.page params[:page]\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @pages }\n end\n end", "def publishing_api_pa...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
PATCH/PUT /contentperpages/1 PATCH/PUT /contentperpages/1.json
def update respond_to do |format| if @contentperpage.update(contentperpage_params) format.html { redirect_to @contentperpage, notice: 'Contentperpage was successfully updated.' } format.json { render :show, status: :ok, location: @contentperpage } else format.html { render :edit ...
[ "def update\n authorize @page_content.page, :update?\n\n respond_to do |format|\n if @page_content.update(page_content_params)\n format.json { render :show, status: :ok, location: @page_content }\n else\n format.json { render json: @page_content.errors, status: :unprocessable_entity }\...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
DELETE /contentperpages/1 DELETE /contentperpages/1.json
def destroy @contentperpage.destroy respond_to do |format| format.html { redirect_to contentperpages_url, notice: 'Contentperpage was successfully destroyed.' } format.json { head :no_content } end end
[ "def destroy\n @content_page = ContentPage.find(params[:id])\n @content_page.destroy\n\n respond_to do |format|\n format.html { redirect_to content_pages_url }\n format.json { head :no_content }\n end\n end", "def delete_page(id)\n @client.raw('delete', \"/content/pages/#{id}\")\n end",...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
Adds authentication information to the request based on the challenge from the response.
def respond_to_challenge(request, response) authenticate_header = response['www-authenticate'].downcase authenticate_header.sub!(/^digest /, '') @authentication_params = authenticate_header.split(", ").inject({}) { |h, field| key, value = field.split("=") h[key] = value.gsub(/^"|"$/, ...
[ "def add_authentication(_, request)\n request.headers['X-User-Email'] = self.class.api_user_email\n request.headers['X-User-Token'] = self.class.api_token\n end", "def continue_with_auth(request_id:, auth_challenge_response:)\n {\n method: \"Fetch.continueWithAuth\",\n params: { re...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
Shorthand for "public && public_write"
def fully_public? public && public_write end
[ "def public?\n rights == 'public'\n end", "def public_writer?\n options[:writer] == :public\n end", "def public_write! if_metageneration_match: nil\n update_predefined_acl! \"publicReadWrite\", if_metageneration_match: if_metageneration_match\n end", "def writable?() en...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
Same as +format_name+ but with id tacked on.
def unique_format_name string_with_id(format_name) end
[ "def unique_format_name\n format_name + \" (#{id || \"?\"})\"\n end", "def unique_partial_format_name\n string_with_id(partial_format_name)\n end", "def format_identifier\n self.identifier.to_s\n end", "def format_identifier\n self.identifier.to_s\n end", "def for...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
Same as +partial_text_name+ but with id tacked on.
def unique_partial_text_name string_with_id(partial_text_name) end
[ "def unique_text_name\n text_name + \" (#{id || \"?\"})\"\n end", "def get_full_name_with_id\n \"#{editable_name} (#{id})\"\n end", "def text_with_id( text, id )\n assert_not text.nil?\n assert_not id.nil?\n assert text.is_a? String\n assert id.is_a? Integer\n \"#{ text } [#{ id }]\"\n e...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
Same as +partial_format_name+ but with id tacked on.
def unique_partial_format_name string_with_id(partial_format_name) end
[ "def unique_format_name\n format_name + \" (#{id || \"?\"})\"\n end", "def unique_format_name\n string_with_id(format_name)\n end", "def format_identifier\n self.identifier.to_s\n end", "def format_identifier\n self.identifier.to_s\n end", "def get_full_name_with_...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
Returns a Hash containing all the descriptive text fields. (See also the counterpart writermethod +all_notes=+.)
def all_notes result = {} self.class.all_note_fields.each do |field| value = send(field).to_s result[field] = value.presence end result end
[ "def fields_description\n\t\treturn self.class.fields.keys.collect do |name|\n\t\t\tval = self.instance_variable_get( \"@#{name}\" )\n\t\t\t\"%s: %s\" % [\n\t\t\t\tname,\n\t\t\t\ttruncate_string( val.inspect, 20 )\n\t\t\t]\n\t\tend.join( ' ' )\n\tend", "def personal_information\n hash = {}\n frm.table(:clas...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
Update all the descriptive text fields via Hash. hash = name.all_notes hash[:look_alikes] = "new value" name.all_notes = hash
def all_notes=(notes) self.class.all_note_fields.each do |field| send("#{field}=", notes[field]) end end
[ "def notes=(value)\n @notes = value\n end", "def add_hike_details\r\n WashingtonHikes::Scraper.scrape_wta_hike_description(self.url).each {|key, value| self.send((\"#{key}=\"), value)}\r\n end", "def set_NotesInfo(value)\n set_input(\"NotesInfo\", value)\n end", "def ...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
Find out how much descriptive text has been written for this object. Returns the number of fields filled in, and how many characters total. num_fields, total_length = name.note_status
def note_status field_count = size_count = 0 all_notes.each_value do |v| if v.present? field_count += 1 size_count += v.strip_squeeze.length end end [field_count, size_count] end
[ "def description_length(pr)\n pull_req = pull_req_entry(pr)\n title = unless pull_req['title'].nil? then pull_req['title'] else ' ' end\n body = unless pull_req['body'].nil? then pull_req['body'] else ' ' end\n (title + ' ' + body).gsub(/[\\n\\r]\\s+/, ' ').split(/\\s+/).size\n end", "def name_length...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
Retreive object representing the source (if applicable). Presently, this only works for Project drafts and User's personal descriptions. All others return +nil+.
def source_object case source_type # (this may eventually be replaced with source_id) when "project" then project when "source" then nil # (haven't created "Source" model yet) when "user" then user end end
[ "def source_object\n Source.find_by_name(source)\n end", "def source\n @sources.first if defined?(@sources)\n end", "def source\n @source ||= PublicEarth::Db::Source.for_user(self)\n end", "def external_source_detail\n return @external_source_detail\n end", ...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
Does this Description belong to a given Project?
def belongs_to_project?(project) (source_type == "project") && (project_id == project.id) end
[ "def project?\n course_type_name == \"project\"\n end", "def has_project?\n !project_id.nil? && project.visible\n end", "def construction_project?\n self.category_ids.include?(4)\n end", "def is_for_project?\n not self.project.nil?\n end", "def is_assigned?(project)\n projects.include?(pr...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
List of all the writers for this description, as ids.
def writer_ids group_user_ids(writers_join_table) end
[ "def writers\n handle(@client.get(\"writers\")) { |result| result[\"writers\"] }\n end", "def writers\n names = full_credits.at(\"a[name='writers']\").parent.parent.parent.parent.css(\"a[href^='/name/nm']\").map { |node| node.text } rescue []\n links = full_credits.at(\"a[name='writers']\")....
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
List of all the readers for this description, as ids.
def reader_ids group_user_ids(readers_join_table) end
[ "def ids_reader\n reader\n @target.map(&:id)\n end", "def get_project_readers\n @project.readers\n end", "def ids_reader; end", "def author_ids\n @instance.client.listAuthorsOfPad(padID: @id)[:authorIDs] || []\n end", "def index\n @readers = Reader.all\n end", "def i...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
Is a given user an writer for this description?
def writer?(user) public_write || permitted?(writers_join_table, user) end
[ "def writer_user? email\n lookup_access_role_scope_value :writer, :user, email\n end", "def is_writer?\n self.role? :writer\n end", "def is_readable_by( user )\n if self.is_public || self.accepts_role?( :owner, user ) \n return true\n else\n return( self.accepts_role? :re...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
Is a given user an reader for this description?
def is_reader?(user) public || permitted?(readers_join_table, user) end
[ "def reader_user? email\n lookup_access_role_scope_value :reader, :user, email\n end", "def is_reviewer?(user)\n review_result = self.design_review_results.detect { |drr| drr.reviewer == user }\n review_result != nil\n end", "def is_readable_by( user )\n if self.is_public || self.a...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
Give a User or UserGroup writer privileges.
def add_writer(arg) chg_permission(writers, arg, :add) end
[ "def add_writer_user email\n add_access_role_scope_value :writer, :user, email\n end", "def add_writer_group email\n add_access_role_scope_value :writer, :group, email\n end", "def permits_write_access_for(user)\n permits_access_for(user, :w)\n end", "def permit...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
Give a User or UserGroup reader privileges.
def add_reader(arg) chg_permission(readers, arg, :add) end
[ "def make_reader!( user )\n self.accepts_role :reader, user\n end", "def assign_reader(user_id)\n add_user(user_id)\n end", "def permits_read_access_for(user)\n permits_access_for(user, :r)\n end", "def assign_reader(user_id)\n\t\tadd_user(user_id)\n\tend", "def add_reader_user email\n ...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
Revoke a User's or UserGroup's writer privileges.
def remove_writer(arg) chg_permission(writers, arg, :remove) end
[ "def revoke_privileges(username=false, database=false, *privileges)\n grant_or_revoke_privileges('REVOKE', username, database, privileges)\n end", "def remove_writer_user email\n remove_access_role_scope_value :writer, :user, email\n end", "def revoke_all_access!\n user_name = a...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
Is the given User an author?
def author?(user) authors.member?(user) end
[ "def author?(user)\n self.user == user\n end", "def current_user_is_author?\n current_user && current_user.is_author\n end", "def has_author?(author)\n ret = false\n @authors.each{ |auth| ret = true if auth == author }\n ret\n end", "def author?\n !author.nil? && !author.empty?\...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
Is the given User an editor?
def editor?(user) editors.member?(user) end
[ "def current_user_is_editor?(node)\n current_user_has_role?('editor', node)\n end", "def is_editor?\n @role && @role.match(/editor|manager/)\n end", "def is_editor?\n role == \"editor\"\n end", "def editor?\n has_role? :editor\n end", "def is_editor?\n if current_user || current_u...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
Add a User on as an "author". Saves User if changed. Returns nothing.
def add_author(user) return if authors.member?(user) authors.push(user) SiteData.update_contribution(:add, authors_join_table, user.id) return unless editors.member?(user) editors.delete(user) SiteData.update_contribution(:del, editors_join_table, user.id) end
[ "def add_author\n add_author_editor \"author\"\n end", "def add_author_or_editor\n return unless !@save_without_our_callbacks && (user = User.current)\n\n authors.empty? && author_worthy? ? add_author(user) : add_editor(user)\n end", "def set_author_values_for(user)\n self.author = user\n ...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
:section: Callbacks Callback that updates editors and/or authors after a User makes a change. If the Name has no author and they've made sufficient contributions, they get promoted to author by default. In all cases make sure the user is added on as an editor.
def add_author_or_editor return unless !@save_without_our_callbacks && (user = User.current) authors.empty? && author_worthy? ? add_author(user) : add_editor(user) end
[ "def add_author(user)\n return if authors.member?(user)\n\n authors.push(user)\n SiteData.update_contribution(:add, authors_join_table, user.id)\n return unless editors.member?(user)\n\n editors.delete(user)\n SiteData.update_contribution(:del, editors_join_table, user.id)\n end", "def set_auth...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
returns only value part of value block
def value(block_num = nil) v, _ = value_with_addr(block_num) v end
[ "def unparsed_value; end", "def get_literal_value()\n @hash[:value]\n end", "def process_field_value(value)\r\n value\r\n end", "def value() end", "def raw_value\n @value\n end", "def value(*) end", "def vlets() [ @value ]; end", "def complete_value\n if last_...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
The method should return the number of pairs of elements that sum to 0.
def pairs_to_zero(nums) # Write your code here c = [] a = nums.select { |n| c.push(n) if n < 0 } nums.delete_if { |n| c.push(n) if n < 0 } i = 0 pairs = 0 a = a.map { |n| n*-1 } loop do if nums.count(a[i]) > 0 pairs += 1 end i += 1 break if i == ...
[ "def pairs_to_zero(nums)\n\n count = 0\n newArr = []\n\n for i in 0..nums.length do\n for j in 1..nums.length do\n if nums[i].to_i + nums[j].to_i == 0\n count = count + 1\n end\n end\n end\n return count-2\nend", "def opposite_count(nums)\n zeros = 0...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
subtract attrs_skip from attrs
def ext_attrs(values, attrs_skip = []) result = values.except *attrs_always_skip return result end
[ "def skip!(name)\n options = { skip: true }\n add_attribute(name, options)\n end", "def exclude_attrs\n # This handle especial case: round and team doesn't have update action\n user_exclusion = if record_is_a?(:round) || record_is_a?(:team)\n @exclude_att...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
Run startup tasks, then start the functions framework server in the background. The startup tasks and target function will be looked up in the global registry.
def start target, &block require "functions_framework/server" if target.is_a? ::FunctionsFramework::Function function = target else function = global_registry[target] raise ::ArgumentError, "Undefined function: #{target.inspect}" if function.nil? end globals = funct...
[ "def start!\n message \"Launching minimum_instances\"\n launch_minimum_instances\n message \"Waiting for master to boot up\" \n \n wait_for_all_instances_to_boot\n \n setup_cloud\n end", "def run\n return self if error?\n case @what_to_do\n when :version\n ...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
Classlevel client class config. Note: late evaluation of `client_class` blocks allows us using classlevel configs in those blocks, e.g.: class ConfigurableOnClassLevel < Netzke::Base class_attribute :title self.title = "Default" client_class do |c| c.title = self.title end end ConfigurableOnClassLevel.title = "Overridd...
def client_class_config return @client_class_config if @client_class_config @client_class_config = Netzke::Core::ClientClassConfig.new(self, called_from) (@configure_blocks || []).each do |block, dir| @client_class_config.dir = dir block&.call(@client_class_config) ...
[ "def set_client_class(cls)\n @@client_class = cls\n end", "def client_class\n @client_class ||= client_class_name.constantize\n end", "def server_side_config_options\n [:klass, :client_config]\n end", "def defclass\n rule(Stone::AST::Statement::Class).sep('class').iden...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
Hash containing configuration for all child components to be instantiated at the JS side
def js_components @js_components ||= eagerly_loaded_components.inject({}) do |out, name| instance = component_instance(name.to_sym) out.merge(name => instance.js_config) end end
[ "def js_configure(c)\n # Merge in component config options, besides those that are only meant for the server side\n # c.merge!(config.reject{ |k,v| self.class.server_side_config_options.include?(k.to_sym) })\n c.merge!(normalized_config)\n\n # Unique id of the component\n c.id = js_id\n\n ...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
All the JScode required by this instance of the component to be instantiated in the browser, excluding cached code. It includes JSclasses for the parents, eagerly loaded child components, and itself.
def js_missing_code(cached = []) code = dependency_classes.inject('') do |r, k| cached.include?(k.client_class_config.xtype) ? r : r + k.client_class_config.code_with_dependencies end code.blank? ? nil : Netzke::Core::DynamicAssets.minify_js(code) end
[ "def js_components\n @js_components ||= eagerly_loaded_components.inject({}) do |out, name|\n instance = component_instance(name.to_sym)\n out.merge(name => instance.js_config)\n end\n end", "def js_components\n @js_components ||= eagerly_loaded_components.inject({}) do |out, (name...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
with the same values except the vowels removed remove_vowels(%w(abcdefghijklmnopqrstuvwxyz)) == %w(bcdfghjklmnpqrstvwxyz) remove_vowels(%w(green YELLOW black white)) == %w(grn YLLW blck wht) remove_vowels(%w(ABC AEIOU XYZ)) == ['BC', '', 'XYZ'] create method remove_vowels that takes an array called strings iterate with...
def remove_vowels(strings) strings.map { |string| string.delete "aeiouAEIOU" } end
[ "def remove_vowels(arr)\n arr.map { |string| string.gsub(/[aeiou]/i, '') }\nend", "def remove_vowels(ary)\n ary.map {|word| word.gsub(/[aeiouAEIOU]/, '')}\nend", "def remove_vowels(array)\n array.map { |string| string.gsub(/[aeiou]/i, '') }\nend", "def remove_vowels(words)\n words.map do |word|\n word....
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
Ask the influencer to link his twitter account
def link_twitter end
[ "def twitter\n end", "def twitter\n process_login\n end", "def twitter_link(player)\n if player.twitter_screen_name\n # clean up any bad characters in a player's twitter name\n twitter_user = player.twitter_screen_name.sub(/^.*[@\\/]/, '')\n\n link_to(\"@\" + twitter_user, \"http://twitte...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
Omniauth setup phase hook, that is used to dynamically set up a omniauth strategy for provider on customer basis
def auth_setup service = Person::OmniauthService::SetupPhase.new(community: @current_community, params: params, request: request) service.run render :plain => "Setup complete.", :status => 404 #This notifies the ominauth to continue end
[ "def omniauth(provider, *args); end", "def facebook_setup\n request.env[\"omniauth.strategy\"].options[:client_id] = @current_community.facebook_connect_id || APP_CONFIG.fb_connect_id\n request.env[\"omniauth.strategy\"].options[:client_secret] = @current_community.facebook_connect_secret || APP_CONFIG.fb_c...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
Callback from Omniauth failures
def failure origin_locale = get_origin_locale(request, available_locales()) I18n.locale = origin_locale if origin_locale error_message = params[:error_reason] || "login error" kind = request.env["omniauth.error.strategy"].name.to_s || "Facebook" flash[:error] = t("devise.omniauth_callbacks.failure",...
[ "def failure\n I18n.locale = URLUtils.extract_locale_from_url(request.env['omniauth.origin']) if request.env['omniauth.origin']\n error_message = params[:error_reason] || \"login error\"\n kind = env[\"omniauth.error.strategy\"].name.to_s || \"Facebook\"\n flash[:error] = t(\"devise.omniauth_callbacks.f...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
same as onstatechange_register, but autounregisters if the block returns true
def onstatechange_register_once handle = onstatechange_register { |st| onstatechange_unregister(handle) if yield(st) } end
[ "def on_actuator_state(&block)\n\t\t\t@on_actuator_state = block\n\t\tend", "def register_state_handler(state, &block)\n register(state_key(state), &block)\n end", "def register_state_handler(state, &block)\n register(\"state_#{state}\", &block)\n end", "def on_led_change( &block )\n @led_h...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
return true if the argument is under the cursor
def at_cursor?(obj) same_pos?(obj, cursor) end
[ "def move_up?\n @cursor > 0\n end", "def needs_cursor?\n\t\t@show_cursor\n\tend", "def cursor_left?\r\n @item_window.index % 2 == 0\r\n end", "def cursor_movable?\n active\n end", "def cursor_movable?\n return false\n end", "def same_cursor_position?\n window.cursor[1] == @history.s...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
returns true if both arguments are at the same x/y/z
def same_pos?(pos1, pos2) pos1 = pos1.pos if pos1.respond_to?(:pos) pos2 = pos2.pos if pos2.respond_to?(:pos) pos1.x == pos2.x and pos1.y == pos2.y and pos1.z == pos2.z end
[ "def Point3dEqual(arg0, arg1)\n ret = _invoke(1610743875, [arg0, arg1], [VT_BYREF | VT_DISPATCH, VT_BYREF | VT_DISPATCH])\n @lastargs = WIN32OLE::ARGV\n ret\n end", "def == point\t\n\t\t@x == point.x && @y == point.y\t\n\tend", "def Range3dEqual(arg0, arg1)\n ret = _invoke(1610744093, [arg0, arg1],...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
try to match a userspecified name to one from the raws uses caseswitching and substring matching eg match_rawname('coal', ['COAL_BITUMINOUS', 'BAUXITE']) => 'COAL_BITUMINOUS'
def match_rawname(name, rawlist) rawlist.each { |r| return r if name == r } rawlist.each { |r| return r if name.downcase == r.downcase } may = rawlist.find_all { |r| r.downcase.index(name.downcase) } may.first if may.length == 1 end
[ "def is_proper(name)\n return name == (name[0].upcase + name[1..-1].downcase)\nend", "def get_perhiperal_default_name(raw_name)\n if bettermatch = /(?<better>[A-Z0-9]{3,})/.match(raw_name)\n return bettermatch[:better]\n end\n\n return raw_name\nend", "def proper_name(name)\n return name if name =~ ...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
Returns true if the version is in the range of this VersionRange object. Uses OSGi versioning rules to determine if the version is in range.
def in_range(version) return in_range(version.min) && (version.max_infinite ? true : in_range(version.max)) if version.is_a?(VersionRange) result = min_inclusive ? min <= version : min < version if (!max_infinite) result &= max_inclusive ? max >= version : max > version end ...
[ "def version_in_range?(range)\n minimum_platform_version = Versionomy.parse(range.first)\n maximum_platform_version = Versionomy.parse(range.last)\n @version >= minimum_platform_version && @version <= maximum_platform_version\n end", "def version_in_range?(range)\n if range.is_a? ...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }