query
stringlengths
7
9.5k
document
stringlengths
10
1.07M
negatives
listlengths
19
19
metadata
dict
The default value of a field using a SQL expression. It can only be set for top level fields (columns). Default value for the entire struct or array is set using a struct or array expression. The valid SQL expressions are: Literals for all data types, including STRUCT and ARRAY. The following functions: `CURRENT_TIMEST...
def default_value_expression @gapi.default_value_expression end
[ "def column_definition_default_sql(sql, column)\n sql << \" DEFAULT (#{literal(column[:default])})\" if column.include?(:default)\n end", "def column_definition_default_sql(sql, column)\n sql << \" DEFAULT #{literal(column[:default])}\" if column.include?(:default)\n end", "def default_value...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
Updates the default value expression of the field.
def default_value_expression= default_value_expression @gapi.update! default_value_expression: default_value_expression end
[ "def default_value_expression\n @gapi.default_value_expression\n end", "def default(field, value)\n @defaults[field] = value\n end", "def default_for( field, value )\r\n f = @fields.find {|f| f.name == field}\r\n raise FieldError, \"unknown field '#{field}'\" if f.nil?\...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
Checks if the type of the field is `STRING`.
def string? type == "STRING" end
[ "def string?\n type == \"string\"\n end", "def isString\n @RecordType == STRING\n end", "def must_be_a_string(value)\n value.is_a?(String)\n end", "def string?(value)\n value.is_a?(String)\n end", "def isUstring\n @RecordType == USTRING\n end", "def isStrtype\n ...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
Checks if the type of the field is `NUMERIC`.
def numeric? type == "NUMERIC" end
[ "def is_numeric?\n data_type == 'number'\n end", "def numeric?\n NUMERIC_TYPES.include?(column_type)\n end", "def force_numeric?(column)\n (column.nil? || [:integer, :float, :decimal].include?(column.type))\n end", "def numerical?\n [:integer, :double, :float, :decimal].incl...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
Checks if the type of the field is `BIGNUMERIC`.
def bignumeric? type == "BIGNUMERIC" end
[ "def numeric?\n type == \"NUMERIC\"\n end", "def numeric?\n NUMERIC_TYPES.include?(column_type)\n end", "def type_literal_generic_bignum(column)\n :bigint\n end", "def is_numeric?\n data_type == 'number'\n end", "def type_literal_generic_bignum_symbol(column)\...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
Checks if the type of the field is `BOOLEAN`.
def boolean? type == "BOOLEAN" || type == "BOOL" end
[ "def validate_boolean_type(field)\n if field.is_a?(TrueClass) || field.is_a?(FalseClass)\n return true\n else\n return false\n end\n end", "def validate_boolean_type(field)\n if field.is_a?(TrueClass) || field.is_a?(FalseClass)\n return true\n else\n return false\n ...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
Checks if the type of the field is `BYTES`.
def bytes? type == "BYTES" end
[ "def type_bytes(type, length); end", "def binary?\n t = @type.downcase\n !!((t =~ /binary/) || (t =~ /blob/))\n end", "def byte? = unit == 'byte'", "def equal_bytesize?(string)\n bytesize == string.bytesize\n end", "def as_many_bytes_as?(other)\n type_id.abs >= other.type_id.abs # TODO:...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
Checks if the type of the field is `TIMESTAMP`.
def timestamp? type == "TIMESTAMP" end
[ "def timestamp?\n type == \"timestamp\"\n end", "def timestamp?\n is_timestamp\n end", "def check_timestamp!(timestamp)\n raise ArgumentError, 'Timestamp must be a Time' unless timestamp.is_a? Time\n end", "def check_timestamp(timestamp)\n fail ArgumentError, 'Time...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
Checks if the type of the field is `TIME`.
def time? type == "TIME" end
[ "def validate_time_field data, fieldname\n time = data[fieldname]\n return false if time.nil?\n return time.class == Fixnum\n end", "def is_time t\r\n return false unless t.instance_of? Time\r\n return true\r\n end", "def time_value?(input)\n return input.is_a?(...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
Checks if the type of the field is `DATETIME`.
def datetime? type == "DATETIME" end
[ "def datetime?\n [:datetime, :time, :timestamp].include?(type)\n end", "def apply_validations_for_datetime\n flex_column_class.validates_each field_name do |record, attr, value|\n record.errors.add(attr, \"must be a Time or DateTime\") if value && (! value.kind_of?(Time)) && (value.cla...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
Checks if the type of the field is `DATE`.
def date? type == "DATE" end
[ "def date?\n type == :date\n end", "def looks_like_date?(value)\n value.is_a?(Date) || value.is_a?(Time)\n end", "def is_date_field?(fieldname)\n self.date_fields.include?(fieldname.to_sym)\n end", "def is_date d\r\n return false unless d.instance_of? Date\r\n return ...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
Checks if the type of the field is `GEOGRAPHY`.
def geography? type == "GEOGRAPHY" end
[ "def polygon?\n 'polygon' == self.type\n end", "def is_xy?(); @type == GRT_XY; end", "def geographic?\n _geographic?\n end", "def geo\n geo_property ? geo_property.ruby_value : nil\n end", "def is_simple?\n postgis_calculate(:issimple, self)\n end", "def geo_coded?\n ...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
Checks if the type of the field is `RECORD`.
def record? type == "RECORD" || type == "STRUCT" end
[ "def record?\n type.record?\n end", "def record_with_type?(record)\n record.include?(\"type\") && !record[\"type\"].nil? && !record[\"type\"].empty?\n end", "def a_record?\n return @is_a_record if defined?(@is_a_record)\n return unless dns?\n\n @is_a_record = Dnsruby::Ty...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
Adds a boolean field to the nested schema of a record field. This can only be called on fields that are of type `RECORD`.
def boolean name, description: nil, mode: :nullable, policy_tags: nil record_check! add_field name, :boolean, description: description, mode: mode, policy_tags: policy_tags end
[ "def boolean(*attrs)\n add_to_schema :boolean, attrs\n end", "def boolean(*attrs)\n add_to_schema :boolean, attrs\n end", "def get_boolean_field(field)\n as_boolean(get_field(field))\n end", "def map_bool(model_field, public_field)\n map_from_public public_field do |value|\n...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
Adds a bytes field to the nested schema of a record field. This can only be called on fields that are of type `RECORD`.
def bytes name, description: nil, mode: :nullable, policy_tags: nil, max_length: nil record_check! add_field name, :bytes, description: description, mode: mode, policy_tags: policy_tags, ...
[ "def bytes name, description: nil, mode: :nullable,\n policy_tags: nil, max_length: nil, default_value_expression: nil\n add_field name, :bytes,\n description: description,\n mode: mode,\n policy_tags: policy_tags,\n ...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
Adds a timestamp field to the nested schema of a record field. This can only be called on fields that are of type `RECORD`.
def timestamp name, description: nil, mode: :nullable, policy_tags: nil record_check! add_field name, :timestamp, description: description, mode: mode, policy_tags: policy_tags end
[ "def timestamp name, description: nil, mode: :nullable\n add_field name, :timestamp, nil, description: description, mode: mode\n end", "def timestamp name, description: nil, mode: nil\n add_field name, :timestamp, nil, description: description, mode: mode\n end", "def set_create_...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
Adds a time field to the nested schema of a record field. This can only be called on fields that are of type `RECORD`.
def time name, description: nil, mode: :nullable, policy_tags: nil record_check! add_field name, :time, description: description, mode: mode, policy_tags: policy_tags end
[ "def time name, description: nil, mode: :nullable,\n policy_tags: nil, default_value_expression: nil\n add_field name, :time,\n description: description,\n mode: mode,\n policy_tags: policy_tags,\n default_value_exp...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
Adds a datetime field to the nested schema of a record field. This can only be called on fields that are of type `RECORD`.
def datetime name, description: nil, mode: :nullable, policy_tags: nil record_check! add_field name, :datetime, description: description, mode: mode, policy_tags: policy_tags end
[ "def datetime name, description: nil, mode: :nullable,\n policy_tags: nil, default_value_expression: nil\n add_field name, :datetime,\n description: description,\n mode: mode,\n policy_tags: policy_tags,\n defau...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
Adds a date field to the nested schema of a record field. This can only be called on fields that are of type `RECORD`.
def date name, description: nil, mode: :nullable, policy_tags: nil record_check! add_field name, :date, description: description, mode: mode, policy_tags: policy_tags end
[ "def date name, description: nil, mode: :nullable,\n policy_tags: nil, default_value_expression: nil\n add_field name, :date,\n description: description,\n mode: mode,\n policy_tags: policy_tags,\n default_value_exp...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
Adds a geography field to the nested schema of a record field.
def geography name, description: nil, mode: :nullable, policy_tags: nil record_check! add_field name, :geography, description: description, mode: mode, policy_tags: policy_tags end
[ "def geography name, description: nil, mode: :nullable,\n policy_tags: nil, default_value_expression: nil\n add_field name, :geography,\n description: description,\n mode: mode,\n policy_tags: policy_tags,\n de...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
Adds a record field to the nested schema of a record field. A block must be passed describing the nested fields of the record. For more information about nested and repeated records, see [Preparing Data for BigQuery]( This can only be called on fields that are of type `RECORD`.
def record name, description: nil, mode: nil record_check! # TODO: do we need to raise if no block was given? raise ArgumentError, "a block is required" unless block_given? nested_field = add_field name, :record, description: description, mode: mode yield ne...
[ "def record name, description: nil, mode: nil\n fail ArgumentError, \"nested RECORD type is not permitted\" if @nested\n fail ArgumentError, \"a block is required\" unless block_given?\n nested_schema = self.class.new nil, true\n yield nested_schema\n add_field name, :re...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
==Execute db migration tasks pdm database migrate up|down|reset PATH/TO/STEP1 PATH/TO/STEP2 task: up/down/reset/backup
def migrate(task, *step_files) step_files = begin Dir[File.join(File.dirname(__FILE__),"../../migrate/*.rb")] end if step_files.empty? establish! do step_files.each do |step_file| require step_file File.basename(step_file) =~ /(.*)\.rb$/ migration ...
[ "def run_migration; end", "def run_migrations(options = {})\n migrator.run(options)\n end", "def migrate\n with_maintenance do\n backup if backup?\n run_migration\n restart\n end\n end", "def do_migrations\n migration_path = File.join(\"generators\", \"talia\", \"templ...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
GET /music_discs GET /music_discs.json
def index @music_discs = MusicDisc.all end
[ "def index\n @musics = Music.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @musics }\n end\n end", "def disc(id)\n get(\"/catalog/titles/discs/#{id.to_s}\")\n end", "def index\n # @musics = Music.all\n # @musics = []\n @musics = S...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
POST /music_discs POST /music_discs.json
def create @music_disc = MusicDisc.new(music_disc_params) @music_disc.user = current_user respond_to do |format| if @music_disc.save format.html { redirect_to @music_disc } format.json { render :show, status: :created, location: @music_disc } else format.html { render :ne...
[ "def create\n @musiccd = Musiccd.new(musiccd_params)\n\n respond_to do |format|\n if @musiccd.save\n format.html { redirect_to @musiccd, notice: 'Musiccd was successfully created.' }\n format.json { render :show, status: :created, location: @musiccd }\n else\n format.html { rend...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
DELETE /music_discs/1 DELETE /music_discs/1.json
def destroy @music_disc.destroy respond_to do |format| format.html { redirect_to music_discs_url } format.json { head :no_content } end end
[ "def destroy\n @musica.audios.purge\n @musica.destroy\n respond_to do |format|\n format.html { redirect_to musicas_url, notice: 'Álbum apagado com sucesso!' }\n format.json { head :no_content }\n end\n end", "def destroy\n @music = Music.find_by_sql(\"SELECT * FROM Musics M Where M.id = ...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
POST /points POST /points.xml
def create @point = Point.new(params[:point]) respond_to do |format| if @point.save format.html { redirect_to(@point, :notice => 'Point was successfully created.') } format.xml { render :xml => @point, :status => :created, :location => @point } else format.html { render :ac...
[ "def create\n @point = Point.new(params[:point])\n\n respond_to do |format|\n if @point.save\n format.html { redirect_to(@point, :notice => 'Point added') }\n format.xml { render :xml => @point, :status => :created, :location => @point }\n else\n format.html { render :action =>...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
GET /store_managers GET /store_managers.json
def index @store_managers = StoreManager.all end
[ "def managers\n response = request(:get, \"/manager\")\n response_to_array(response, \"managers\", KontaktIo::Resource::Manager)\n end", "def index\n @manager_stores = ManagerStore.all\n end", "def managers(params = {})\n response = get('/api/manager', params)\n\n response.map do |manager...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
POST /store_managers POST /store_managers.json
def create @store_manager = StoreManager.new(store_manager_params) respond_to do |format| if @store_manager.save format.html { redirect_to @store_manager, notice: 'Store manager was successfully created.' } format.json { render :show, status: :created, location: @store_manager } els...
[ "def create\n authorize! :create, Manager\n store = Store.find(params[:store_id])\n @manager = store.managers.create(manager_params)\n\n respond_to do |format|\n if @manager.save\n format.html { redirect_to store_manager_path(@manager.store,@manager) }\n format.json { render :show, st...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
PATCH/PUT /store_managers/1 PATCH/PUT /store_managers/1.json
def update respond_to do |format| if @store_manager.update(store_manager_params) format.html { redirect_to @store_manager, notice: 'Store manager was successfully updated.' } format.json { render :show, status: :ok, location: @store_manager } else format.html { render :edit } ...
[ "def update\n authorize! :update, Manager\n respond_to do |format|\n if @manager.update(manager_params)\n format.html { redirect_to store_managers_path }\n format.json { render :show, status: :ok, location: @manager }\n else\n format.html { render :edit }\n format.json { ...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
DELETE /store_managers/1 DELETE /store_managers/1.json
def destroy @store_manager.destroy respond_to do |format| format.html { redirect_to store_managers_url, notice: 'Store manager was successfully destroyed.' } format.json { head :no_content } end end
[ "def destroy\n @manager_store.destroy\n respond_to do |format|\n format.html { redirect_to manager_stores_url, notice: 'Manager store was successfully destroyed.' }\n format.json { head :no_content }\n end\n end", "def destroy\n @admin_store = Admin::Store.find(params[:id])\n @admin_stor...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
Public: Search for schedules that will soon overdue range The overdue time, must be UTC int (Default: 4.days) Returns the Mongoid::Criteria
def soon range=4.days schedules.where(:when.lte => range.from_now) end
[ "def client_tasks_overdue\n self.find_all {|e| (e.completed.nil? or !e.completed) and e.complete_by < Time.zone.now }\n end", "def reservation_criteria(worker, right_now, max_run_time)\n criteria = where(\n run_at: { '$lte' => right_now },\n failed_at: nil\n ).a...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
Lazily fetches all builds.
def builds(filters = {}) fetch_resources_lazily("builds", filters) end
[ "def list_all\n response_json = @client.api_get_request(\"/api/build\")\n\n return nil unless response_json\n\n response_json[\"builds\"].map do |build|\n {\n :name => build[\"uri\"].sub(/^\\//,''),\n :uri => build[\"uri\"],\n :lastStarted => build[\"la...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
ENV['PVC_DEPLOY_TO_BASE'] = stage_data[:deploy_to] || '/sites'
def deploy_to_base_dir # stage[:deploy_to] || '/sites' # TODO: verify if server setup supports `:deploy_to` override Pvcglue.configuration.web_app_base_dir # TODO: server setup does not yet support `:deploy_to` override, and would have to be refactored at a higher level than stage. end
[ "def deploy_to_base_dir\n # stage[:deploy_to] || '/sites' # TODO: verify if server setup supports `:deploy_to` override\n web_app_base_dir # TODO: server setup does not yet support `:deploy_to` override, and would have to be refactored at a higher level than stage.\n end", "def site_dir\n ENV['SIT...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
GET /cooperatives GET /cooperatives.json
def index @cooperatives = Cooperative.all end
[ "def index\n @councils = Council.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @councils }\n end\n end", "def index\n @representatives = current_company.representatives\n\n respond_to do |format|\n format.html # index.html.erb\n form...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
POST /cooperatives POST /cooperatives.json
def create @cooperative = Cooperative.new(cooperative_params) respond_to do |format| if @cooperative.save format.html { redirect_to @cooperative, notice: 'Cooperative was successfully created.' } format.json { render :show, status: :created, location: @cooperative } else for...
[ "def create\n @covariate = Covariate.new(covariate_params)\n\n respond_to do |format|\n if @covariate.save\n format.html { redirect_to @covariate, notice: 'Covariate was successfully created.' }\n format.json { render :show, status: :created, location: @covariate }\n else\n form...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
PATCH/PUT /cooperatives/1 PATCH/PUT /cooperatives/1.json
def update respond_to do |format| if @cooperative.update(cooperative_params) format.html { redirect_to @cooperative, notice: 'Cooperative was successfully updated.' } format.json { render :show, status: :ok, location: @cooperative } else format.html { render :edit } forma...
[ "def update\n respond_to do |format|\n if @person_cocoon.update(person_cocoon_params)\n format.html { redirect_to @person_cocoon, notice: 'Person cocoon was successfully updated.' }\n format.json { render :show, status: :ok, location: @person_cocoon }\n else\n format.html { render ...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
DELETE /cooperatives/1 DELETE /cooperatives/1.json
def destroy @cooperative.destroy respond_to do |format| format.html { redirect_to cooperatives_url, notice: 'Cooperative was successfully destroyed.' } format.json { head :no_content } end end
[ "def destroy\n @cooperative.destroy\n respond_to do |format|\n format.html { redirect_to cooperatives_url }\n format.json { head :no_content }\n end\n end", "def delete_tenant_circle(args = {}) \n delete(\"/tenantcircles.json/#{args[:circleId]}\", args)\nend", "def destroy\n @json.destroy...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
functions for seeing if moves are valid Top
def canMoveTop(row,col,disc) max = @size -1 min = 0 notDisc = "" c = 1 if disc == "B" notDisc = "W" end if disc == "W" notDisc = "B" end if row-c >= min && @board[row-c][col] == notDisc while row-c >= min && @b...
[ "def at_top?(square, player)\n square[0] == top(player)\n end", "def validate_top_coordinates\n self.add_error \"Invalid Top coordinates\" if self.top_x.to_i <= 0 || self.top_y.to_i <= 0\n end", "def valid_move_onto?(pile)\n if self.foundation? && !self.empty? && !pile.empty? &&\n (sel...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
Places the disc of current player at row,col and flips the opponent discs as needed
def placeDiscAt(row, col) if (!isValidMove(row, col)) return end # place the current player's disc at row,col @board[row][col] = @disc # TO DO: COMPLETE THIS PART OF THE METHOD c = 1 notDisc = "" if @disc == "B" notDisc = "W" ...
[ "def placeDiscAt(row, col)\n\t\tif (!isValidMove(row, col))\n\t\t\treturn\n\t\tend\n\n #\n # TO DO: add your code below\n\t\t#\n\t\t@board[row][col] = @disc;\n\t\t# flips any opponent discs down\n\t\tr = row + 1\n\t\tc = col\n\t\twhile r < @size && @board[r][c] != EMPTY && @board[r][c] != @disc do\n\t\t\t\tr ...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
Returns command to grep config file for assignment
def grep_cmd sprintf 'grep -Fq "%s" %s', key_set_string, @file end
[ "def lookup_config\n # pull in a config if it exists\n return false unless File.exists? @config_build\n\n @knife_commands = JSON.parse File.open( @config_build, 'r' ){|f| f.read }\n end", "def construct_exist_command\n \"#{@executables[:ip]} addr show #{device} | grep -wq -E \\\"^\\\\W*inet #{@na...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
Returns command to append assignment to config file
def append_cmd sprintf 'echo "%s%s" >> %s', key_set_string, @config[:value], @file end
[ "def construct_add_command\n \"#{@executables[:ip]} addr add #{name} dev #{device}\"\n end", "def configure_command(cmd)\n end", "def append_config_file(filename, line)\n File.open(filename, \"a\") { |f| f.puts(line) }\n end", "def set_command(command)\n @custom['command'] = comman...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
Returns command to remove assignment from config file
def unset_cmd sprintf 'sed -i /%s/d %s', key_set_string, @file end
[ "def remove_command(name)\n @commands ||= {}\n @commands.delete name\n end", "def remove_config(name)\n\t\tend", "def remove_command(name)\n @embedded_commands.delete(name.to_sym)\n end", "def construct_delete_command\n \"#{@executables[:ip]} addr del #{name} dev #{device}\"\n end...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
find out the weightage for first record of the exam
def weightage return unless exams.first.nil? exams.first.weightage end
[ "def get_weight(details)\n details.select{ |k,v| k.include?('Weight') }.first.last\n end", "def weight\n return @weight\n end", "def weight\n # TODO: auto unit conversion\n measurement(8).try(:measurement)\n end", "def weight\n\n @db.fsiz\n end", "def w...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
Generate the result by subject id and exam group id.
def exam_data(subject) Exam.result(subject.id, id) end
[ "def generate_grouped_report2\n @students ||= @batch.students\n @student = @batch.students.first\n @exam_groups ||= @batch.result_published\n @subjects ||= @batch.subjects\n end", "def generate_subject_report2\n @batch = @subject.batch\n @exam_groups ||= @batch.result_published\n @students |...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
This action manage the type of exam result i.e.Grades or Marks.
def type_result(e, es) if exam_type == 'Grades' es.grading_level.name || 'AB' elsif exam_type == 'Marks' [es.marks || 'AB', e.maximum_marks].join('/') else [[es.marks || 'AB', e.maximum_marks].join('/'), es.grading_level.name || '-'].join('|') end end
[ "def exam_result\n if params[:exam_id]\n @exam = Exam.find(params[:exam_id])\n assert(exam.kind_of?(Exam))\n @exam = fill_user_answers(@exam)\n\n current_user.exams_total_questions += @exam.questions.count\n current_user.update_attribute(:exam_performance, current_user.exam_performance +...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
Calculating the exam marks.
def exam_mar(subject, student, marks) exam = exam_data(subject) exam_score = exam.scores(student) return if exam.nil? marks.to_f + exam_score.marks.to_f end
[ "def earned_marks\n answers.map{ |x| x.earned_marks }.inject(0, :+)\n end", "def calculate_marks\n stream = Stream.find(stream_id)\n sub_maps = stream.sub_str_maps.all\n xuser = self.user\n xcategory = xuser.personal.category\n xacademic = xuser.academic\n tenth_mark = xacademic.tenth_marks\...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
GET /venue_products/1 GET /venue_products/1.json
def show @venue_product = VenueProduct.find(params[:id]) respond_to do |format| format.html # show.html.erb format.json { render json: @venue_product } end end
[ "def show\n @v1_product = V1::Product.find(params[:id])\n\n render json: @v1_product\n end", "def index\n @api_v1_products = Product.all\n json_response(@api_v1_products)\n end", "def index\n @v1_products = V1::Product.all\n if @v1_products.empty?\n render json: @v1_products, message: 'Re...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
GET /venue_products/new GET /venue_products/new.json
def new @venue_product = VenueProduct.new respond_to do |format| format.html # new.html.erb format.json { render json: @venue_product } end end
[ "def new\n @product = Product.new\n\n render json: @product\n end", "def new\n @title = t('view.products.new_title')\n @product = Product.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @product }\n end\n end", "def new\n @collection_prod...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
PUT /venue_products/1 PUT /venue_products/1.json
def update @venue_product = VenueProduct.find(params[:id]) respond_to do |format| if @venue_product.update_attributes(params[:venue_product]) format.html { redirect_to @venue_product, notice: 'Venue product was successfully updated.' } format.json { head :ok } else format.ht...
[ "def update\n begin\n @api_v1_product.update!(api_v1_product_params)\n head :no_content\n rescue => ex\n json_response({error: ex.message}, :unprocessable_entity)\n end\n end", "def update\n @v1_product = V1::Product.find(params[:id])\n\n if @v1_product.update(v1_product_params)\n ...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
DELETE /venue_products/1 DELETE /venue_products/1.json
def destroy @venue_product = VenueProduct.find(params[:id]) @venue_product.destroy @venue = Venue.find_by_fs_venue_id(@venue_product.fs_venue_id) @venue.update_attribute(:product_count,(@venue.product_count).to_i - 1) respond_to do |format| format.html { redirect_to venue_products_url } ...
[ "def destroy\n @productos_json.destroy\n respond_to do |format|\n format.html { redirect_to productos_jsons_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @onecompany_product = Onecompany::Product.find(params[:id])\n @onecompany_product.destroy\n\n respond_to do...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
GET /class_mstrs/1 GET /class_mstrs/1.json
def show @class_mstr = ClassMstr.find(params[:id]) respond_to do |format| format.html # show.html.erb format.json { render json: @class_mstr } end end
[ "def new\n @class_mstr = ClassMstr.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @class_mstr }\n end\n end", "def create\n @class_mstr = ClassMstr.new(params[:class_mstr])\n\n respond_to do |format|\n if @class_mstr.save\n format.htm...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
GET /class_mstrs/new GET /class_mstrs/new.json
def new @class_mstr = ClassMstr.new respond_to do |format| format.html # new.html.erb format.json { render json: @class_mstr } end end
[ "def create\n @class_mstr = ClassMstr.new(params[:class_mstr])\n\n respond_to do |format|\n if @class_mstr.save\n format.html { redirect_to @class_mstr, notice: 'Class mstr was successfully created.' }\n format.json { render json: @class_mstr, status: :created, location: @class_mstr }\n ...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
POST /class_mstrs POST /class_mstrs.json
def create @class_mstr = ClassMstr.new(params[:class_mstr]) respond_to do |format| if @class_mstr.save format.html { redirect_to @class_mstr, notice: 'Class mstr was successfully created.' } format.json { render json: @class_mstr, status: :created, location: @class_mstr } else ...
[ "def new\n @class_mstr = ClassMstr.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @class_mstr }\n end\n end", "def create\n init = params[:mclass][:name][0]\n mclass_number = Mclass.create_number(params)\n @mclass = Mclass.new(mclass_params.me...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
PUT /class_mstrs/1 PUT /class_mstrs/1.json
def update @class_mstr = ClassMstr.find(params[:id]) respond_to do |format| if @class_mstr.update_attributes(params[:class_mstr]) format.html { redirect_to @class_mstr, notice: 'Class mstr was successfully updated.' } format.json { head :no_content } else format.html { rende...
[ "def create\n @class_mstr = ClassMstr.new(params[:class_mstr])\n\n respond_to do |format|\n if @class_mstr.save\n format.html { redirect_to @class_mstr, notice: 'Class mstr was successfully created.' }\n format.json { render json: @class_mstr, status: :created, location: @class_mstr }\n ...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
DELETE /class_mstrs/1 DELETE /class_mstrs/1.json
def destroy @class_mstr = ClassMstr.find(params[:id]) @class_mstr.destroy respond_to do |format| format.html { redirect_to class_mstrs_url } format.json { head :no_content } end end
[ "def destroy\n @clclass = Clclass.find(params[:id])\n @clclass.destroy\n\n respond_to do |format|\n format.html { redirect_to clclasses_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @class_name.destroy\n respond_to do |format|\n format.html { redirect_to r...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
Replaces the CORS rules attached to this bucket. You can pass one or more rules as an array or a list. replace all exisitng rules with a single rule bucket.cors.set( :allowed_methods => %w(GET), :allowed_origins => %w( :max_age_seconds => 3600) If you pass an empty array, all of the rules will be removed from the bucke...
def set *rules raise ArgumentError, 'expected one or more rules' if rules.empty? if rules == [[]] self.clear else rules = rule_hashes(rules) client.put_bucket_cors(:bucket_name => bucket.name, :rules => rules) end nil end
[ "def cors=(rules)\n if rules.empty?\n @protocol.delete_bucket_cors(name)\n else\n @protocol.set_bucket_cors(name, rules)\n end\n end", "def set_bucket_cors(name, rules)\n logger.info(\"Begin set bucket cors, bucket: #{name}, rules: \"\\\n \"#{...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
Removes all CORS rules attached to this bucket. bucket.cors.count => 3 bucket.cors.clear bucket.cors.count => 0
def clear client.delete_bucket_cors(:bucket_name => bucket.name) nil end
[ "def delete_cors\n @bucket_cors.delete\n true\n rescue Aws::Errors::ServiceError => e\n puts \"Couldn't delete CORS rules for #{@bucket_cors.bucket.name}. Here's why: #{e.message}\"\n false\n end", "def removed_cors\n @aws.cors.rules - (@local.cors || [])\n end", "def delete_bucket_cor...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
/ Initialize zbuffer, projection matrix, light source, and lighting model. Do not specify a material property here.
def myinit position = [0.0, 3.0, 3.0, 0.0]; local_view = [0.0]; GL.Enable(GL::DEPTH_TEST); GL.DepthFunc(GL::LESS); GL.Light(GL::LIGHT0, GL::POSITION, position); GL.LightModel(GL::LIGHT_MODEL_LOCAL_VIEWER, local_view); GL.FrontFace(GL::CW); GL.Enable(GL::LIGHTING); GL.E...
[ "def init\n mat_specular = [ 1.0, 1.0, 1.0, 1.0 ];\n light_position = [ 1.0, 1.0, 1.0, 0.0 ];\n\n GL.ClearColor(0.0, 0.0, 0.0, 0.0);\n GL.ShadeModel(GL::SMOOTH);\n GL.Enable(GL::DEPTH_TEST);\n GL.Material(GL::FRONT, GL::DIFFUSE, $diffuseMaterial);\n GL.Material(GL::FRONT, GL::SPECULAR, mat_specular);\...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
GET /claim_submissions/1 GET /claim_submissions/1.json
def show @claim_submission = ClaimSubmission.find(params[:id]) respond_to do |format| format.html # show.html.erb format.json { render json: @claim_submission } end end
[ "def new\n @claim_submission = ClaimSubmission.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @claim_submission }\n end\n end", "def get_contact_submissions(contact_id)\n @client.raw('get', \"/crm/contacts/#{contact_id}/submissions\")\n end", "de...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
GET /claim_submissions/new GET /claim_submissions/new.json
def new @claim_submission = ClaimSubmission.new respond_to do |format| format.html # new.html.erb format.json { render json: @claim_submission } end end
[ "def new\n @submission = Submission.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @submission }\n end\n end", "def create\n @claim_submission = ClaimSubmission.new(params[:claim_submission])\n\n respond_to do |format|\n if @claim_submission...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
POST /claim_submissions POST /claim_submissions.json
def create @claim_submission = ClaimSubmission.new(params[:claim_submission]) respond_to do |format| if @claim_submission.save format.html { redirect_to @claim_submission, notice: 'Claim submission was successfully created.' } format.json { render json: @claim_submission, status: :created...
[ "def create\n submission = Submission.new(submission_params)\n unless submission.save\n render json: {errors: submmission.errors.full_messages}, status: :bad_request\n return\n end\n\n claim = Claim.new(\n insured_id: submission.insured_id,\n provider_id: submission.provider_id\n ...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
PUT /claim_submissions/1 PUT /claim_submissions/1.json
def update @claim_submission = ClaimSubmission.find(params[:id]) respond_to do |format| if @claim_submission.update_attributes(params[:claim_submission]) format.html { redirect_to @claim_submission, notice: 'Claim submission was successfully updated.' } format.json { head :no_content } ...
[ "def create\n submission = Submission.new(submission_params)\n unless submission.save\n render json: {errors: submmission.errors.full_messages}, status: :bad_request\n return\n end\n\n claim = Claim.new(\n insured_id: submission.insured_id,\n provider_id: submission.provider_id\n ...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
DELETE /claim_submissions/1 DELETE /claim_submissions/1.json
def destroy @claim_submission = ClaimSubmission.find(params[:id]) @claim_submission.destroy respond_to do |format| format.html { redirect_to claim_submissions_url } format.json { head :no_content } end end
[ "def destroy\n response = RestClient.delete $api_service+\"/claim_issues/\"+params['id']\n redirect_to :action => \"index\"\n end", "def destroy\n @claim.destroy\n respond_to do |format|\n format.html { redirect_to claims_url }\n format.json { head :no_content }\n end\n end", "def des...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
GET /aircraft_histories/1 GET /aircraft_histories/1.xml
def show @aircraft_history = AircraftHistory.find(params[:id]) respond_to do |format| format.html # show.html.erb format.xml { render :xml => @aircraft_history } end end
[ "def rss\n @event = Event.find_by_key(params['id'])\n @histories = @event.histories(:order => 'created_at DESC')\n render :layout => false\n response.headers[\"Content-Type\"] = \"application/xml; charset=utf-8\"\n end", "def index\n @histories = History.all_by_user(current_user).order_by_happened...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
GET /aircraft_histories/new GET /aircraft_histories/new.xml
def new @aircraft_history = AircraftHistory.new respond_to do |format| format.html # new.html.erb format.xml { render :xml => @aircraft_history } end end
[ "def new\n @historial = Historial.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @historial }\n end\n end", "def create\n @aircraft = Aircraft.find(params[:aircraft_id])\n @aircraft_history = @aircraft.aircraft_histories.create(params[:aircraft...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
POST /aircraft_histories POST /aircraft_histories.xml
def create @aircraft = Aircraft.find(params[:aircraft_id]) @aircraft_history = @aircraft.aircraft_histories.create(params[:aircraft_history]) redirect_to aircraft_path(@aircraft) end
[ "def create\n megam_rest.post_billedhistories(to_hash)\n end", "def new\n @aircraft_history = AircraftHistory.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @aircraft_history }\n end\n end", "def create\n @historial = Historial...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
PUT /aircraft_histories/1 PUT /aircraft_histories/1.xml
def update @aircraft_history = AircraftHistory.find(params[:id]) respond_to do |format| if @aircraft_history.update_attributes(params[:aircraft_history]) format.html { redirect_to(@aircraft_history, :notice => 'Aircraft history was successfully updated.') } format.xml { head :ok } ...
[ "def update\n @historial_oct = HistorialOct.find(params[:id])\n\n respond_to do |format|\n if @historial_oct.update_attributes(params[:historial_oct])\n format.html { redirect_to @historial_oct, notice: 'Historial oct was successfully updated.' }\n format.json { head :no_content }\n el...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
DELETE /aircraft_histories/1 DELETE /aircraft_histories/1.xml
def destroy @aircraft_history = AircraftHistory.find(params[:id]) @aircraft_history.destroy respond_to do |format| format.html { redirect_to(aircraft_histories_url) } format.xml { head :ok } end end
[ "def destroy\n @aircraft = Aircraft.find(params[:id])\n @aircraft.destroy\n add_to_log(t('Aircraft destroy log') + @aircraft.name,\"aircrafts\",\"destroy\")\n\n respond_to do |format|\n format.html { redirect_to(aircrafts_url) }\n format.xml { head :ok }\n end\n end", "def destroy\n ...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
Dump one fact type.
def fact_type_dump(fact_type, name) @fact_types_dumped[fact_type] = true return objectified_fact_type_dump(fact_type.entity_type) if fact_type.entity_type puts fact_type.scala_definition @metamodel << fact_type.scala_metamodel end
[ "def fact_type_dump(fact_type, name)\n return if skip_fact_type(fact_type)\n o = fact_type.entity_type\n\n primary_supertype = o && (o.identifying_supertype || o.supertypes[0])\n secondary_supertypes = o.supertypes-[primary_supertype]\n\n # Get the preferred identifier, but don't ...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
authenticate_admin GET /user_funs GET /user_funs.json
def index @user_funs = UserFun.all respond_to do |format| format.html # index.html.erb format.json { render :json => @user_funs } end end
[ "def my_fun_list\n @user_funs = UserFun.find_all_by_user_id(current_user.id)\n end", "def show\n @user_fun = UserFun.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render :json => @user_fun }\n end\n end", "def my_fun_list\n user_funs = User...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
GET /user_funs/new GET /user_funs/new.json
def new @user_fun = UserFun.new respond_to do |format| format.html # new.html.erb format.json { render :json => @user_fun } end end
[ "def new\n @funny = current_user.funnies.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @funny }\n end\n end", "def new\n @fun = Fun.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render :json => @fun }\n ...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
PUT /user_funs/1 PUT /user_funs/1.json
def update @user_fun = UserFun.find(params[:id]) respond_to do |format| if @user_fun.update_attributes(params[:user_fun]) format.html { redirect_to @user_fun, :notice => 'User fun was successfully updated.' } format.json { head :no_content } else format.html { render :action...
[ "def update\n respond_to do |format|\n if @fun.update(fun_params)\n format.html { redirect_to @fun, notice: 'Fun was successfully updated.' }\n format.json { render :show, status: :ok, location: @fun }\n else\n format.html { render :edit }\n format.json { render json: @fun.e...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
DELETE /user_funs/1 DELETE /user_funs/1.json
def destroy @user_fun = UserFun.find(params[:id]) @user_fun.destroy respond_to do |format| format.html { redirect_to user_funs_url } format.json { head :no_content } end end
[ "def destroy\n @fun = Fun.find(params[:id])\n @fun.destroy\n\n respond_to do |format|\n format.html { redirect_to funs_url }\n format.json { head :no_content }\n end\n end", "def delete_user_for_tenant(args = {}) \n delete(\"/tenants.json/#{args[:tenantId]}/users/#{args[:userId]}\", args)\n...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
authenticate_user register fun POST /user_funs POST /user_funs.json create INPUT: fun_id (value) OUTPUT: SAVE user_fun (UserFun.object), fun.popularity +1 FROM: views/funs/list_selected TO: 2012.7.6 Yueying
def create hash = params[:register] if hash != nil user_fun = UserFun.new user_fun.user_id = current_user.id hash_invert = hash.invert user_fun.fun_id = hash_invert.values_at("register").first.to_i user_fun.save fun = user_fun.fun sql = ActiveRecord::Base.connection(...
[ "def create\n hash = params[:register]\n\n if hash != nil\n user_fun = UserFun.new\n user_fun.user_id = session[:user_id]\n hash_invert = hash.invert\n user_fun.fun_id = hash_invert.values_at(\"register\").first.to_i\n user_fun.save\n\n fun = user_fun.fun\n sql = ActiveReco...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
attend fun attend INPUT: user_fun_id (value), user_id (session value) OUTPUT: SAVE user_point, team_point, user_fun.attend FROM: /views/funs/my_fun_list TO: 2012.7.17 Yueying
def attend # update user_fun.is_attend user_fun = UserFun.find(params[:user_fun_id]) user_fun.update_attribute(:is_attend, 1) # save user_point user_point = UserPoint.new user_point.add_point(current_user.id, 30000, 'fun') # save team_point team_point = TeamPoint.new team = Tea...
[ "def attend\n @demo_day.add_attendee!(current_user)\n redirect_to :action => :index\n end", "def attend\n @auth = User.find_by(email: current_userlogin.email)\n redirect_to memberDashboard_path unless @auth\n @point_event = PointEvent.find(params[:id])\n @user = User.where(email: current_userlo...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
Downloads the source file to the destination file. It is up to implementors of this class to handle the logic.
def download!(source_url, destination_file); end
[ "def download_from_source(destination_path)\n self.file_path = destination_path\n download = Downloads::File.new(source, destination_path, :referer_url => referer_url)\n download.download!\n ugoira_service.load(download.data)\n download.source\n end", "def download_file source, destina...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
GET /outmails GET /outmails.json
def index @outmails = Outmail.all end
[ "def index\n @outcoming_mails = OutcomingMail.all\n end", "def index\n @outmessages = Outmessage.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render :json => @outmessages }\n end\n end", "def outbox\n session[:mail_box] = \"outbox\"\n @emails = rezm...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
POST /outmails POST /outmails.json
def create @outmail = Outmail.new(outmail_params) respond_to do |format| if @outmail.save format.html { redirect_to @outmail, notice: 'Outmail was successfully created.' } format.json { render :show, status: :created, location: @outmail } else format.html { render :new } ...
[ "def index\n @outmails = Outmail.all\n end", "def destroy\n @outmail.destroy\n respond_to do |format|\n format.html { redirect_to outmails_url, notice: 'Outmail was successfully destroyed.' }\n format.json { head :no_content }\n end\n end", "def create\n @outgoing_mail = OutgoingMail....
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
PATCH/PUT /outmails/1 PATCH/PUT /outmails/1.json
def update respond_to do |format| if @outmail.update(outmail_params) format.html { redirect_to @outmail, notice: 'Outmail was successfully updated.' } format.json { render :show, status: :ok, location: @outmail } else format.html { render :edit } format.json { render json...
[ "def update\n @outgoing_mail = OutgoingMail.find(params[:id])\n\n respond_to do |format|\n if @outgoing_mail.update_attributes(params[:outgoing_mail])\n format.html { redirect_to @outgoing_mail, notice: 'Outgoing mail was successfully updated.' }\n format.json { head :ok }\n else\n ...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
DELETE /outmails/1 DELETE /outmails/1.json
def destroy @outmail.destroy respond_to do |format| format.html { redirect_to outmails_url, notice: 'Outmail was successfully destroyed.' } format.json { head :no_content } end end
[ "def destroy\n @outgoing_mail = OutgoingMail.find(params[:id])\n @outgoing_mail.destroy\n\n respond_to do |format|\n format.html { redirect_to outgoing_mails_url }\n format.json { head :ok }\n end\n end", "def destroy\n @mail.destroy\n respond_to do |format|\n format.html { redir...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
Return a unary minus function
def unary_minus UnaryMinus.new(self) end
[ "def unary\r\n if consume(\"+\")\r\n unary()\r\n elsif consume(\"-\")\r\n new_binary(ND_SUB, new_num(0), unary())\r\n else\r\n primary()\r\n end\r\nend", "def subtract\n match '-'\n term\n emit_ln 'SUB (SP)+, D0'\n emit_ln 'NEG D0'\nend", "def unary(ex,op)\n nil\n end", "def negate\n ...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
Returns a new +Mail::Part+ with the same content and MIME headers as the message passed as an argument. Although Mail gem provides +Mail::Messageconvert_to_multipart+ method, it works correctly for nonmultipart text/plain messages only. This method is more robust, and handles messages containing any content type, be th...
def body_to_part(message) part = ::Mail::Part.new part.content_type = message.content_type if message.multipart? message.body.parts.each { |p| part.add_part duplicate_part(p) } else part.body = message.body.decoded end part end
[ "def convert_message(message)\n SmsSafe::Message.new(from: message.from, to: message.to, text: message.text, original_message: message)\n end", "def convert_message(msg)\n\n $stderr.puts \"%sConverting message:\\n%s\" % \n [ $indent, msg.header.to_s.gsub(/^/, $indent+' ') ] if $DEBUG\n\n # Text/...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
Duplicates a message part, preserving its ContentID if present.
def duplicate_part(part) duplicate = part.dup duplicate.add_content_id(part.content_id) unless part.content_id.nil? duplicate end
[ "def duplicate\n dup_frames = @msg_frames.map {|frame| frame.dup}\n ZMQ::StringMultipartMessage.new(dup_frames)\n end", "def scrub_duplicate_message(message)\n messages do |collection|\n idx = collection[message.connection.identifier].index do |msg|\n msg.message_id == mess...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
Detects email which should be used to find a message signer key. Basically, it is taken from the message +From:+ field, but may be overwritten by +:signer+ adapter option.
def find_signer_for(message) options[:signer] || message.from_addrs.first end
[ "def sender_email\n msg['from_email'] || msg['sender'] || entry['sender'] || reject['sender']\n end", "def from_email\n AppConfig[:pui_request_email_fallback_from_address]\n end", "def sender_email\n @message['sender']\n end", "def signer_params\n valid_params.select { |k, v| k.end_with?('_name...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
Replaces a message body. Clears all the existing body, be it multipart or not, and then appends parts passed as an argument.
def rewrite_body(message, content_type:, parts: []) message.body = nil message.content_type = content_type parts.each { |p| message.add_part(p) } end
[ "def replace_in_pure_html_message(new_part)\n if new_part.content_type.include?('text/html')\n message.body = new_part.decoded\n message.content_type = new_part.content_type\n else\n message.body = nil\n message.content_type = new_part.content_type\n new_pa...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
Importing translations for given page. They look like `content.locale.html`
def import_translations(path, page) old_translations = page.translations.pluck(:locale) new_translations = [] Dir["#{path}content.*.html"].each do |file_path| locale = File.basename(file_path).match(%r{content\.(\w+)\.html})[1] new_translations << locale translation = page.tr...
[ "def i18n\n %w(en es).each do |locale|\n copy_file \"i18n.#{ locale }.yml\", \"config/locales/seo_landing_pages.#{ locale }.yml\"\n end\n end", "def fetch_from_pages\n self.mounting_point.pages.values.each do |page|\n page.translated_in.each do |locale|\n Locomot...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
Constructing frag attributes hash that can be assigned to page or translation also returning list of frag identifiers so we can destroy old ones
def construct_fragments_attributes(hash, record, path) frag_identifiers = [] frag_attributes = hash.collect do |frag_header, frag_content| tag, identifier = frag_header.split frag_hash = { identifier: identifier, tag: tag } # tracking fragments tha...
[ "def to_hash\n fattrs.inject({}){|h,a| h.update a => send(a)}\n end", "def fragment=(v); self[:fragment]=v end", "def keys(fragName)\r\n fragName = @base_path+fragName\r\n frag = @fragments[fragName]\r\n frag = build(fragName) unless frag\r\n return frag.keys if frag\r\n end", "def ...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
Preparing fragment attachments. Returns hashes with file data for ActiveStorage and a list of ids of old attachements to destroy
def files_content(record, identifier, path, frag_content) # preparing attachments files = frag_content.split("\n").collect do |filename| file_handler = File.open(File.join(path, filename)) { io: file_handler, filename: filename, content_type: MimeM...
[ "def parsed_attachments_from_params\n return unless (attachments = params[:attachments])\n\n attachments.delete_if {|_key, value| Attachment.find_by_token(value[:token]).nil? }\n attachments\n end", "def construct_fragments_attributes(hash, record, path)\n frag_identifiers = []\n frag_attribut...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
callseq: shim[index] = value Sets the _value_ at the given _index_. The array shim applies it's offset to the _index_ before setting the _value_.
def []=( index, value ) @ary[index + @offset] = value end
[ "def set(index, val)\n \n end", "def set(index, value)\n raise IndexError if index >= @n\n @data[index + @size_r] = value\n end", "def set(index, element)\n index = index.to_i\n raise OutOfBoundsException unless valid_index?(index)\n @array[index] = element\n end", "def []=(index, v...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
Initialize the WindowsLiveLogin module with the application ID, secret key, and security algorithm. We recommend that you employ strong measures to protect the secret key. The secret key should never be exposed to the Web or other users. Be aware that if you do not supply these settings at initialization time, you may ...
def initialize(appid=nil, secret=nil, securityalgorithm=nil) self.appid = appid if appid self.secret = secret if secret self.securityalgorithm = securityalgorithm if securityalgorithm end
[ "def app_init\n @vk = VK::Serverside.new app_id:APP_ID, app_secret: APP_SECRET#, settings: SETTINGS\n @vk.settings = SETTINGS\n @vk.access_token = session[:access_token] if isAuth?\n end", "def initialize(config_file=CONFIG_FILE)\n confs = YAML.load_file(config_file)['windows_live']\n @wll = W...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
Processes the login response from Windows Live Login. 'query' contains the preprocessed POST table such as that returned by CGI.params or by Rails (the unprocessed POST string might also be used here but we do not recommend it). The method returns a User object on successful login; otherwise nil.
def processLogin(query) query = parse query unless query debug("Error: processLogin: Failed to parse query.") return end action = query['action'] unless action == 'login' debug("Warning: processLogin: query action ignored: #{action}.") return end token = query['stoken...
[ "def process_login_response(email, password, response)\n @email = email\n @password = password\n @token = Parser.extract_user_token response\n @id = Parser.login_object_id response\n @xp = Parser.extract_xp response\n end", "def user_login\n @retval = Hash.new()\n unless params[:username].bl...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
Returns the sign in URL to use for Windows Live Login. We recommend that you use the Sign In control instead. If you specify it, 'context' will be returned asis in the login response for sitespecific use.
def getLoginUrl(context=nil) url = baseurl + "wlogin.srf?appid=#{appid}" url += "&alg=#{securityalgorithm}" url += "&appctx=#{CGI.escape(context)}" if context url end
[ "def login_url\n @env[CLOUDKIT_LOGIN_URL] || '/login'\n end", "def passive_sign_in_uri\n return @passive_sign_in_uri\n end", "def auth_url(options={})\n options = {\n 'api_key' => @api_key,\n 'fbconnect' => true,\n 'v' => API_VER...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
Decodes and validates a Web Authentication token. Returns a User object on success. If a context is passed in, it will be returned as the context field in the User object.
def processToken(token, context=nil) if token.nil? or token.empty? debug("Error: processToken: Null/empty token.") return end stoken = decodeToken token stoken = validateToken stoken stoken = parse stoken unless stoken debug("Error: processToken: Failed to decode/validate token...
[ "def processToken(token, context=nil)\n if token.nil? or token.empty?\n debug(\"Error: processToken: Null/empty token.\")\n return\n end\n stoken = decodeAndValidateToken token\n stoken = parse stoken\n unless stoken\n debug(\"Error: processToken: Failed to decode/validate token: #{tok...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
Decode the given token. Returns nil on failure. First, the string is URL unescaped and base64 decoded. Second, the IV is extracted from the first 16 bytes of the string. Finally, the string is decrypted by using the encryption key.
def decodeToken(token) if (@cryptkey.nil? or @cryptkey.empty?) fatal("Error: decodeToken: Secret key was not set. Aborting.") end token = u64(token) if (token.nil? or (token.size <= 16) or !(token.size % 16).zero?) debug("Error: decodeToken: Attempted to decode invalid token.") return...
[ "def p_decrypt_string(ciphertext, key, iv, algorithm)\n cipher = p_cipher(algorithm)\n cipher.key = key\n cipher.iv = iv\n cipher.decrypt\n # decrypt ciphertext\n encoded_plain = cipher.update(ciphertext)\n encoded_plain << cipher.final\n # return the decoded ...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
Extracts the signature from the token and validates it.
def validateToken(token) if (token.nil? or token.empty?) debug("Error: validateToken: nil/empty token.") return end body, sig = token.split("&sig=") if (body.nil? or sig.nil?) debug("Error: validateToken: Invalid token: #{token}") return end sig = u64(sig) return toke...
[ "def validateToken(token, signkey=@signkey)\n if (token.nil? or token.empty?)\n debug(\"Error: validateToken: Null token.\")\n return\n end\n body, sig = token.split(\"&sig=\")\n if (body.nil? or sig.nil?)\n debug(\"Error: validateToken: Invalid token: #{token}\")\n return\n end\n...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
Returns the trusted login token in the format that is needed by a control doing trusted login. User to be trusted on the local site is passed in as string 'user'.
def getTrustedToken(user) if user.nil? or user.empty? debug('Error: getTrustedToken: Null user specified.') return end token = "appid=#{appid}&uid=#{CGI.escape(user)}&ts=#{timestamp}" token += "&sig=#{e64(signToken(token))}" CGI.escape token end
[ "def login_token(user, expire=0)\n if expire != 0\n expires = Time.now.to_i + expire.to_i\n else\n expires = @cert_chain[0].not_after.to_i\n end\n\n text_to_sign = \"#{user}:#{expires}\"\n signed_text = encrypt(text_to_sign)\n\n certs_pem = @cert_chai...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
Returns the trusted signin URL to use for Windows Live Login.
def getTrustedLoginUrl secureurl + "wlogin.srf" end
[ "def passive_sign_in_uri\n return @passive_sign_in_uri\n end", "def active_sign_in_uri\n return @active_sign_in_uri\n end", "def login_web_url\n return @login_web_url\n end", "def ssl_account_session_url\n account_session_url(:on...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
Returns the trusted signout URL to use for Windows Live Login.
def getTrustedLogoutUrl secureurl + "logout.srf?appid=#{appid}" end
[ "def sign_out_uri\n return @sign_out_uri\n end", "def getTrustedLoginUrl\n secureurl + \"wlogin.srf\"\n end", "def passive_sign_in_uri\n return @passive_sign_in_uri\n end", "def logout_url\n logout_call = prepare_api_call(\"\", :base_url=>ODESK_AUTH...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
Derive the key, given the secret key and prefix as described in the SDK documentation.
def derive(secret, prefix) begin fatal("Nil/empty secret.") if (secret.nil? or secret.empty?) key = prefix + secret key = OpenSSL::Digest::SHA256.digest(key) return key[0..15] rescue Exception => e debug("Error: derive: #{e}") return end end
[ "def derive(secret, prefix)\r\n begin\r\n fatal(\"Nil/empty secret.\") if (secret.nil? or secret.empty?)\r\n key = prefix + secret\r\n key = Digest::SHA256.digest(key)\r\n return key[0..15]\r\n rescue Exception => e\r\n debug(\"Error: derive: #{e}\")\r\n return\r\n end\r\n en...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
grab likes from yesterday
def todays_likes dayEnd = DateTime.now.beginning_of_day dayStart = dayEnd - 1.day likes.where("likes.created_at > ? and likes.created_at < ?", dayStart, dayEnd) end
[ "def list_liked\n TwList.get_or_create(\"#{@account.username} # liked\")\n end", "def my_likes\n @liked_sumpoints = []\n @likes = Like.where(user_id: current_user, value: 1)\n @likes.each do |like|\n @liked_sumpoints << like.sumpoint \n end\n end", "def receive_likers\n media = inst...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }